Skip to content

Instantly share code, notes, and snippets.

@tappoz
Last active September 17, 2019 16:57
Show Gist options
  • Save tappoz/fac760fa2766ebb83062e9f4cce6e631 to your computer and use it in GitHub Desktop.
Save tappoz/fac760fa2766ebb83062e9f4cce6e631 to your computer and use it in GitHub Desktop.

Azure CLI 2.0 cheatsheet

A collection of commands useful to do things in the Azure cloud.

Check the status of instances of SQL Server and databases

$ # Check the state of a SQL Server instance
$ # https://docs.microsoft.com/en-us/cli/azure/sql/server?view=azure-cli-latest#az-sql-server-show
$ az sql server show --name ${SQL_SERVER_NAME} --resource-group ${RESOURCE_GROUP_NAME} | jq .state
"Ready"
$ # Check the status of a database
$ # https://docs.microsoft.com/en-us/cli/azure/sql/db?view=azure-cli-latest#az-sql-db-show
$ az sql db show --name ${DB_NAME} --server ${SQL_SERVER_NAME} --resource-group ${RESOURCE_GROUP_NAME} | jq .status
"Online"

Get VM image details from the Azure marketplace

E.g. https://azuremarketplace.microsoft.com/en-us/marketplace/apps/gitlab.gitlab-ce

To get the publisher, offer, SKU, and version:

$ az vm image list --offer GitLab -o table --all
Unable to load extension 'azure-cli-iot-ext'. Use --debug for more information.
Offer                    Publisher    Sku                  Urn                                                   Version
-----------------------  -----------  -------------------  ----------------------------------------------------  ---------------
gitlab                   Bitnami      8-5                  Bitnami:gitlab:8-5:12.1.1908011456                    12.1.1908011456
gitlab-ce                gitlab       gitlab-ce            gitlab:gitlab-ce:gitlab-ce:1.0.4                      1.0.4
gitlab-ee                gitlab       gitlab-ee            gitlab:gitlab-ee:gitlab-ee:1.0.2                      1.0.2
gitlab-enterprise-ready  meanio       gitlab-ee-basic      meanio:gitlab-enterprise-ready:gitlab-ee-basic:1.0.0  1.0.0
w9gitlabce               websoft9inc  gitlab12-ubuntu1804  websoft9inc:w9gitlabce:gitlab12-ubuntu1804:12.1.0000  12.1.0000

To get the details regarding the plan block:

$ az vm image show --location westus --urn gitlab:gitlab-ce:gitlab-ce:1.0.4 -o json
{
  "automaticOsUpgradeProperties": {
    "automaticOsUpgradeSupported": false
  },
  "dataDiskImages": [],
  "id": "/Subscriptions/${SUBSCRIPTION_ID}/Providers/Microsoft.Compute/Locations/westus/Publishers/gitlab/ArtifactTypes/VMImage/Offers/gitlab-ce/Skus/gitlab-ce/Versions/1.0.4",
  "location": "westus",
  "name": "1.0.4",
  "osDiskImage": {
    "operatingSystem": "Linux",
    "sizeInGb": 30
  },
  "plan": {
    "name": "gitlab-ce",
    "product": "gitlab-ce",
    "publisher": "gitlab"
  },
  "tags": null
}

Retrieve web apps credentials

az webapp deployment list-publishing-credentials \
   --name ${WEB_APP_NAME} --resource-group ${RESOURCE_GROUP_NAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment