Cloud and Datacenter Management Blog

Microsoft Hybrid Cloud blogsite about Management

Install #Azure CLI 2.0 and Run Script for VM with Operations Management Suite Agent #MSOMS

Leave a comment


Download Python for Windows here

Be sure to install the Pip component when you install Python. After the install completes, add Python to your PATH environment variable
(the installer will prompt you).

The Azure CLI 2.0 is Azure’s new command-line experience for managing Azure resources. It can be used on macOS, Linux, and Windows.

Azure CLI 2.0 is optimized for managing and administering Azure resources from the command line, and for building automation scripts that work against the Azure Resource Manager.

Open Command Prompt and type : python –version

To install Azure CLI you have to type the following command :
pip install –user azure-cli

Installing Azure CLI 2.0

Done.
Type Azure

With Microsoft Azure CLI 2.0 scripts you can deploy complete solutions, like this example for a Virtual Machine with Microsoft OMS agent active :

Sample script

#!/bin/sh

# Update for your admin password
AdminPassword=ChangeYourAdminPassword1

# OMS Id and OMS key.
omsid=<Replace with your OMS Id>
omskey=<Replace with your OMS key>

# Create a resource group.
az group create --name myResourceGroup --location westeurope

# Create a virtual machine. 
az vm create \
    --resource-group myResourceGroup \
    --name myVM \
    --image win2016datacenter \
    --admin-username azureuser \
    --admin-password $AdminPassword 

# Install and configure the OMS agent.
az vm extension set \
  --resource-group myResourceGroup \
  --vm-name myVM --name MicrosoftMonitoringAgent \
  --publisher Microsoft.EnterpriseCloud.Monitoring \
  --version 1.0 --protected-settings '{"workspaceKey": "'"$omskey"'"}' \
  --settings '{"workspaceId": "'"$omsid"'"}'

Author: James van den Berg

I'm Microsoft Architect and ICT Specialist and Microsoft MVP Cloud and Datacenter Management

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.