Arc for Servers has an Azure CLI extension and PowerShell module. Because they are prerelease, they are not included (yet) in the main releases
(ie, you don’t get this just by installing az cli or the Az module).
However they are already functional and useful. Here’s how to do some simple operations with each of them.
Install
AZ CLI:
1
|
az extension add connectedmachine
|
Azure PowerShell:
1
|
Install-Module -Name Az.ConnectedMachine
|
List machines
AZ CLI
1
2
3
4
|
az connectedmachine list
# only display a few properties in a convenient form
az connectedmachine list --query "[].{Name:name,ResourceGroup:resourceGroup,Location:location,Status:status}" -o table
|
Azure PowerShell:
List extensions installed on a machine
AZ CLI
1
|
az connectedmachine extension list --resource-group edyoung --machine-name edwin-virtual-machine
|
Azure PowerShell:
1
|
Get-AzConnectedMachineExtension -ResourceGroupName edyoung -MachineName edwin-virtual-machine
|
Install Custom Script Extension on a windows machine and run ‘dir’
Note that installing extensions currently takes several minutes. Please be patient.
AZ CLI run in bash
1
2
|
# Note --location needs to be the location of the machine
az connectedmachine extension create --machine-name silverbox-ne --resource-group edyoung --name myext --type "CustomScriptExtension" --publisher "Microsoft.Compute" --settings '{"commandToExecute":"dir"}' --location "North Europe"
|
AZ CLI run inside PowerShell (the escaping is different for settings param)
1
|
az connectedmachine extension create --machine-name silverbox-ne --resource-group edyoung --name myext --type "CustomScriptExtension" --publisher "Microsoft.Compute" --settings '{\"commandToExecute\":\"dir\"}' --location "North Europe"
|
Azure PowerShell
1
|
New-AzConnectedMachineExtension -MachineName silverbox-ne -ResourceGroupName edyoung -Location "North Europe" -Name myext -Setting '{"commandToExecute":"dir"}' -ExtensionType CustomScriptExtension -Publisher Microsoft.Compute
|
Delete an extension
AZ CLI
1
|
az connectedmachine extension delete --name myext -g edyoung --machine-name silverbox-ne
|
Azure PowerShell
1
|
Remove-AzConnectedMachineExtension -MachineName silverbox-ne -ResourceGroupName edyoung -Name myext
|