How to run Azure Powershell by Ansible or Azure CLI?

Nguyen Van Linh 1 Reputation point
2022-03-11T07:57:38.537+00:00

I am trying to create Runbook in Automation Account so I would like to create by Ansible or Azure CLI which can do it.

I have read some documents that say it is possible to use Azure Powershell. but I don't know of any way to use Azure Powershell through Ansible or Azure CLI or some automatic way. Can someone help me? Thank you.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,366 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. tbgangav-MSFT 10,426 Reputation points Moderator
    2022-03-21T07:46:58.377+00:00

    Hi @Nguyen Van Linh ,

    In addition to my previous comment, I wanted to let you know that this is the Azure CLI command and this is the Azure REST API to create Azure Automation Runbook. Sharing in case you want to give a try using Azure CLI or Azure REST API by leverage this / this Ansible embedded command/shell which can be used to call CLI commnands.

    2 people found this answer helpful.
    0 comments No comments

  2. tbgangav-MSFT 10,426 Reputation points Moderator
    2022-03-16T15:08:12.457+00:00

    Hi @Nguyen Van Linh ,

    Currently there is no direct ansible plugin / module supported for creating Azure Automation runbook. I hope you are aware that these are the currently supported plugins / modules under azure.azcollection collection. This is the feature request for the same which has already been raised in Sep'21. Just now I have request for an update on it and also asked for ETA by when plugin to create runbook under azure.azcollection collection will be available to use. I would recommend to follow it for updates.

    On the other hand, with the features that are currently available, try to leverage ansible.windows.win_powershell plugin / module of ansible.windows collection in your playbook and leverage New-AzAutomationRunbook Azure PowerShell cmdlet under the script parameter of it.

    1 person found this answer helpful.
    0 comments No comments

  3. tbgangav-MSFT 10,426 Reputation points Moderator
    2022-04-03T06:20:49.467+00:00

    Hi @Nguyen Van Linh ,

    I have worked with our internal team and then this feature request is taken care.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.