Last active
August 29, 2020 05:51
-
-
Save acerzhou/71e28ac1580ac06df510975a361d7fae to your computer and use it in GitHub Desktop.
[Azure CLI] Useful Azure CLI Command #Azure #CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create an app service plan | |
az appservice plan create -n <plan_name> --g <resource_group> | |
# Create an App Service Web app | |
az webapp create -n <app_name> -g <resource_group> -p <plan_name> | |
# Create an App Service Web app with docker container | |
az webapp create -n <app_name> -g <group> -p <plan_name> -i <docker_img> | |
# Create an App Service Web App for static html | |
az webapp up -l <region> -n <app_name> --html | |
# Configure a deployment user | |
az webapp deployment user set --user-name <username> --password <pwd> | |
# Get web app deploymetn URL | |
az webapp deployment source config-local-git -n <app_name> -g <resource_group> -o tsv | |
# Delete an App Service Web App | |
az webapp delete -n <app_name> | |
# Set App Service Configuration | |
az webapp config appsettings set -n <name> --settings <setting> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
az group deployment create \ | |
--name ExampleDeployment \ | |
--mode Complete \ | |
--resource-group ExampleGroup \ | |
--template-file storage.json \ | |
--parameters storageAccountType=Standard_GRS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create and register an ad app | |
az ad app create --diaplay-name <name> --reply-url <redirect_url> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create an API Management Instance | |
az apim create -n <apim_name> -l <location> ` | |
--publisher-email <email> ` | |
-g <rescource_group_name> ` | |
--publisher-name <publisher_name> ` | |
--sku-name Consumption | |
# create apim api | |
az apim api create -api-id <name> -g <group> --display-name <name> --path <path> --service-name <service_name> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# show list of azure cdn profile or within some resource group | |
az cdn profile list [--resource-group <group_name>] | |
# create azure cdn profile | |
az cdn profile create --name <cdnname> --resource-group <group> -sku <sku> | |
# Availabile SKU | |
# Custom_Verizon | |
# Premium_Verizon | |
# Standard_Akamai | |
# Standard_ChinaCdn | |
# Standard_Verizon | |
# create a cdn endponit | |
az cdn endpoint create --name <endpoint_name> --origin <url> --profile-name <cdnname> --resource-group <group> | |
# to purge the content | |
az cdn endpoint purge \ | |
--content-paths '/css/*' '/js/app.js' \ | |
--name ContosoEndpoint \ | |
--profile-name DemoProfile \ | |
--resource-group ExampleGroup | |
# to pre load the content | |
az cdn endpoint load \ | |
--content-paths '/img/*' '/js/module.js' \ | |
--name ContosoEndpoint \ | |
--profile-name DemoProfile \ | |
--resource-group ExampleGroup' | |
# Create Azure Redis Cache | |
az redis create -g <group> -n <name> -l <location> --sku <sku> --vm-size <vm_size> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create ACR service | |
az acr create --resource-group <group_name> --name <acrname> --sku basic | |
# Show all image in repository | |
az acr repository list --name <acrname> -o tabl | |
# Show tags of image | |
az acr repository show-tags --name <acrname> --repository <image_name> -o table | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create Azure SQL Server | |
az sql server create -n <name> -g <group> -u <admin_user> -p <pwd> | |
# Create Azure SQL DB | |
az sql db create -n <name> -s <server_name> | |
# Create Cosmos DB | |
az cosmosdb create -n <name> -g <group> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create azure event grid topic | |
az eventgrid topic create -n <name> -g <group> -l <location> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create Azure Function | |
az funcationapp create -n <name> -g <group> -s <storage_account> | |
# Enable identity | |
az functionapp identity assign -g <group> -n <name> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# enable managed identity for web app | |
az web app identity assign --name <app-name> --resource-group <group> | |
# enable managed identity for azure container instances | |
az container create --resource-group <group> --name <contianer_name> --image <img> --assign-identity --command-line "cmd" | |
# create user identity | |
az identity create --resource-group <group> --name <identity_name> | |
# Get identity resource id | |
resourceID=$(az identity show --resource_group <resource_group> --name <identity_name> --query id --output tsv) | |
# Assigned with user created identity | |
az container create -g <group> -n <container_name> --assign_identity $resourceID --image <img> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create key vault | |
az keyvault create -n <name> -g <group> -l <location> | |
# Set Secret Key in Key vault | |
az keyvault secret set --vault-name <vault_name> -name <name> --value <value> | |
# show value of scret in key vault | |
az keyvault secret show --vault-name <vault_name> -name <name> | |
# key vault set policy | |
az keyvault set-policy -n <name> --spn <service_princial_name> --object-id <object_id> --securet-permissions <secret_action> --storage-permissions <storage_action> --certificate-permissions <certificate_action> --key-permissions <key_action> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create Azure Logic App | |
az logic workflow create -n <name> -g <group> -l <location> --definition <definition_in_json> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Azure App Insight create | |
az monitor app-insights component create -n <name> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create an Azure VMs | |
az vm create \ | |
--resource-group myResourceGroup \ | |
--name myVM \ | |
--image win2016datacenter \ | |
--assign-identity \ | |
--admin-username azureuser \ | |
--admin-password myPassword12 | |
# Enable system-assigned managed identity | |
az vm identity assign -g myResourceGroup -n myVm | |
# Create user identity | |
az identity create -g myResourceGroup -n myUserAssignedIdentity | |
# Assign a user-assigned managed identity during creation a VM | |
az vm create \ | |
--resource-group <RESOURCE GROUP> \ | |
--name <VM NAME> \ | |
--image UbuntuLTS \ | |
--admin-username <USER NAME> \ | |
--admin-password <PASSWORD> \ | |
--assign-identity <USER ASSIGNED IDENTITY NAME> | |
# Assigne a user-managed identity to an existing VM | |
az vm identity assign \ | |
-g <RESOURCE GROUP> \ | |
-n <VM NAME> \ | |
--identities <USER ASSIGNED IDENTITY> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# register the Event Grid | |
az provider register --namespace <namespace> | |
# check the status | |
az provider show --namespace <namespace> --query "registrationState" | |
# create a custom topic | |
az eventgrid topic create --name <topic_name> -l <location> -g <group_name> | |
# create a message endpoint | |
az group development create \ | |
-g <group_name> \ | |
--template-uri <template_uri> \ | |
--parameters siteName=<siteName> hostingPlanName=viewerhost | |
# Subscribe to a custom topic | |
az eventgrid event-subscription create \ | |
--source-resource-id <resource_id> \ | |
--name <name> \ | |
--endpoint <endpoint> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check all resource group | |
az group list | |
# Create a resource group | |
az group create -l <region> -n <resource group> | |
# Remove resource group async withoug confirm | |
az group delete -n <resource group> -y --no-wait | |
# Show Azure Provider | |
az provider list | |
# Show all Azure Provider Name | |
az provider list --query "[].namespace" | |
# Register an Azure Provider | |
az provider register -n <namespace> | |
# Unregister an Azure Provider | |
az provider unregister -n <namespace> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a Storage Account | |
az storage account create -g <resource_group> -n <name> -l <region> --kind StorageV2 --access-tier hot --sku Standard_LRS | |
# Get Storage Account Key | |
az storage account keys list -n <name> -g <resource_group> -o table | |
================== Container ================================ | |
# Create a container | |
az storage container create -n <container_name> --account-name <account_name> --account-key <account_key> | |
# Create a container with private access | |
az storage container create -n <container_name> --public-access off --account-name <account_name> --account-key <account_key> | |
================== Blob ================================ | |
# Upload Blob | |
az storage blob upload -c <container_name> -f <path_to_file> -n <file_name> --account-name <account_name> --account-key <account_key> | |
# Upload Blob batch | |
az storage blob upload-batch -d <container_name> -s <path> --account-name <account_name> --account-key <account_key> | |
# Generate sas key | |
az storage blob generate-sas -c <container> -n <name> --permissions r --expiry <expiy_date - 2020-08-19T00:00:00Z> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment