Close
AlgoliaLogoLight
Close full mode
logo

Azure CLI

Git RepositoryEdit on Github

Install Azure CLI on WSL2 (Ubuntu)

Install with one command

$ curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

Update to the latest version

$ az upgrade

Uninstall Azure CLI

Log in Azure CLI

  • Execute the following command
    $ az login
  • A browser will be opened.
  • Log in with your Azure account.
  • Wait for a while and you will get your subscription in JSON format and a shell is read to enter a new command.

List all subscription you have and check a default subscription

az account list --output table

Set a default subscription

az account set --subscription <subscription name or id>

Create a resource group with a default subscription.

az group create --location <location-name> --name <resource-group-name>
  • To list all locations, use az account list-locations --output table.
  • To list all existing resource groups of the default subscription, use az group list --output table.
  • More details for Azure resource group

Get Azure Credentials for azure/login action

  • Run the following command:
az ad sp create-for-rbac \
--name {name} --role contributor \
--scopes /subscriptions/{subscription-id}/resourceGroups/{resource-group} \
--sdk-auth
  • Replace {name}, {subscription-id} and {resource-group} with your name reference, subscription and resource group.
  • The command should return JSON object similar to this:
{
"clientId": "<GUID>",
"clientSecret": "<GUID>",
"subscriptionId": "<GUID>",
"tenantId": "<GUID>",
(...)
}
  • Store the above JSON object as the value of a GitHub secret with a name, for example AZURE_CREDENTIALS
  • Then use a secret in your GitHub Actions workflow script, for example ${{ secrets.AZURE_CREDENTIALS }}

REF

Loading comments...