Azure CLI

Account management defaults

Set subscription by name

subscriptionName="chgeuer-work"
az account set --subscription "${subscriptionName}"

Get subscription ID of current account

subscriptionID="$( az account show --output json | jq -r ".id" )"

Create an ARM deployment and pass in a parameter of type 'object'

The file definition.json contains a JSON object, which is passed as-is into the ARM deployment:

resourceGroup="foo"
logicAppName="someapp"

deploymentResult="$( az group deployment create \
  --resource-group "${resourceGroup}" \
  --mode Incremental \
  --template-file ./azuredeploy-minimal.json \
  --parameters logicAppName="${logicAppName}" \
  --parameters logicAppDefinition="@./definition.json" 
  )"

The template has a corresponding type=object parameter:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "logicAppName": { "type": "string", "defaultValue": "..." },
    "logicAppDefinition": { "type": "object" }
  },
  ...
}

Run the Docker container

docker pull mcr.microsoft.com/azure-cli:latest

docker run --mount "src=${HOME}/.azure,target=/root/.azure,type=bind" -it --rm mcr.microsoft.com/azure-cli:latest

Last updated