Working with VM Extension from Azure Portal
Built Agent or Extension
- Login to Azure portal and go to Virtual Machine dashboard
- Now select your VM and go to Extension + application tab
- Now here you will find predefined agents, you can choose from this list which agent you want to install. For this demo we will install
Microsoft anti-malware
agent, once you select the Microsoft malware agent click on Next
- Now you can customize the installation details like which path to install as well as the frequency of this Anti-virus Agent run or scan. Once you have configured the details of the agent you can click on Review + Create
Custom Script Extension
- Launch Azure Cloud Shell
- Create virtual machine
$cred = Get-Credential
New-AzVm ` -ResourceGroupName "myResourceGroupAutomate" ` -Name "myVM" ` -Location "East US" ` -VirtualNetworkName "myVnet" ` -SubnetName "mySubnet" ` -SecurityGroupName "myNetworkSecurityGroup" ` -PublicIpAddressName "myPublicIpAddress" ` -OpenPorts 80 ` -Credential $cred
- Automate IIS install
Set-AzVMExtension -ResourceGroupName "myResourceGroupAutomate" ` -ExtensionName "IIS" ` -VMName "myVM" ` -Location "EastUS" ` -Publisher Microsoft.Compute ` -ExtensionType CustomScriptExtension ` -TypeHandlerVersion 1.8 ` -SettingString '{"commandToExecute":"powershell Add-WindowsFeature Web-Server; powershell Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"}'
- Test web site
Get-AzPublicIPAddress ` -ResourceGroupName "myResourceGroupAutomate" ` -Name "myPublicIPAddress" | select IpAddress
- You can then enter the public IP address in to a web browser
Tag:Azure