Search code examples
azurepowershellvisual-studio-codeautomationazure-runbook

Possible to connect local PowerShell to Azure Runbooks?


I'm looking for a way to use my machine-local PowerShell ISE or VSCode to connect to Azure Runbooks. Usually, one has to scaffold locally and then test in the cloud in an Azure runbook. Has anybody ever done this?

One way I'm looking into it is this idea but I was wondering if you knew of something more convenient.


Solution

  • To connect from local (VScode) to Azure Runbooks:

    Thanking @Kaido Järvemets for detailed steps. I've tried by considering few steps from there and was able to connect successfully.

    • Check for Azure Automation extension in Visual Studio code.

    enter image description here

    • To work with Azure automation from local, we need to set up a few settings by searching "Preferences: User settings" (ctrl+shift+p).

    • Register a new application under Azure Active Directory and add the respective "client_id, client_secret, automation_account_name, subscription_id,tenant_id" in extension settings of Azure Automation configuration.

    enter image description here

    enter image description here

    • Give the required permissions in Automation Account -> Access Control (IAM) as shown here:

    enter image description here

    • Created a PowerShell runbook script to run connect-AzAccount under Azure Automation Account through portal.

      enter image description here

    • Opened the same runbook in Azure Automation and was able to connect from local (vscode)to Azure.

    enter image description here

    Note: Search for Automation explorer (ctrl+shift+p) and create a new runbook if needed. you can run the same script in Azure portal also & it will work as described above.

    enter image description here