mountainss Cloud and Datacenter Management Blog

Microsoft SystemCenter blogsite about virtualization on-premises and Cloud


Leave a comment

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

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"'"}'

Advertisements