3 min read

How to configure Azure Automation Visual Studio Code Extension

How to configure Azure Automation Visual Studio Code Extension
Azure Automation and Visual Studio Code

What is Azure Automation, and what are the reasons for implementing it

Azure Automation is a cloud-based service you can implement for cloud-only resources or hybrid clouds. Azure Automation provides many features that make our automation more secure and manageable.

Out of the box, you will get the following features:

  • Shared Resources – you can remove the sensitive parts from your scripts and move them to different containers
    o Credentials
    o Connections
    o Certificates
    o Variables
  • Job Statistics – visualized overview of job executions, etc
  • RBAC – You can delegate different permission for different parties in your organization
  • Schedules– you can schedule your scripts
  • Runbooks – all the scripts that you can run on Azure only or in your datacenters
    o These can be PowerShell or Python scripts
  • Hybrid-Worker - you can extend the Azure Automation service to your data centers or other clouds. Hybrid-Worker is just a virtual machine that you can deploy.
  • Azure Log Analytics Integration – send all logs to Log Analytics and create different dashboards or alerts.

This post will show you how to configure the Azure Automation Visual Studio Code extension.

Requirements for VS Code Extension

  • Azure Automation Account
  • Permission to manage Azure Automation Account
  • Azure AD Application for Visual Studio Code
  • Permission to create Azure AD Applications
  • Visual Studio Code

Azure AD Application Configuration

  1. Open Azure Portal – portal.azure.com
  2. Select Azure Active Directory and choose App Registrations.
  3. Select + New Application Registration.
  4. Fill out the details:
    a. Name: Azure Automation Runbook Manager
    b. Supported Account Types: Accounts in this organizational directory only
  5. Click Register.
  6. Copy the Application ID to Notepad.
  7. Click Certificates & secrets and choose Client Secrets.
  8. Click +New Client Secret
  9. Fill out the Key description and duration and click Add.
  10. Copy key value to Notepad.
  11. Close the Azure AD Application configuration panels and return to the main Azure AD configuration panel.
  12. Select Properties and copy the Directory ID to Notepad.

Visual Studio Code configuration

  1. Install Visual Studio Code
    a. https://code.visualstudio.com/download
  2. Open Visual Studio Code
  3. Select Extensions and search for Azure Automation
    Extension
  4. Click Install
  5. After the installation, click Manage and choose Extension Settings
  6. On the Extension Settings page, configure the following values
    a. Automation Account: Azure Automation Account name
    b. Client ID: Azure AD Application ID
    c. Client Secret: Azure AD Application Keys value
    d. Resource Group: Azure Automation Resource Group Name
    e. Subscription ID: Your Azure subscription where you have the Azure Automation Account.
    f. Tenant ID: Azure AD Tenant ID
  7. Close the settings panel

Azure Automation Account Configuration

  1. Open Azure Portal – portal.azure.com
  2. Choose your Azure Automation Account
  3. Select Access Control (IAM)
  4. Choose +Add and select +Add Role Assignment
  5. On the Add Role Assignment page, choose Automation Contributor
  6. Click Next
  7. Select +Select Members
  8. Search the service principal that you created previously
  9. Click Select
  10. Click Review + assign

Testing

  1. In VS Code, select Automation Explorer
  2. Click the + Sign and fill out the Runbook name
    Runbook
  3. Select the language PowerShell or Python
  4. Select the Runtime Version
  5. Write your script and Publish 😊

Available Extension Commands

  • Create Credential Asset
  • Create New Runbook
  • Create Variable Asset
  • Insert Credential Asset
  • Insert Variable Asset
  • Open Runbook from Azure
  • Publish
  • Run
  • Save Draft
  • Update Personal Information

Summary

VS Code makes it much easier for us to develop different solutions. Do not try to author the Runbooks through the web browser.

If you are not using Azure Automation today, I recommend testing it. It is easy to implement and maintain. It provides high-value out of the box.

Need help with Azure Automation implementation, then please let me know.