$ az config set core.output=table
Command group 'config' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
$ az config set extension.use_dynamic_install=yes_prompt
Command group 'config' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
$ az config set extension.run_after_dynamic_install=yes
Command group 'config' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
https://learn.microsoft.com/en-us/cli/azure/azure-cli-configuration
# turn persisted parameters on
az config param-persist on
# Create a resource group which will store "resource group" and "location" in persisted parameter.
az group create --name RGlocalContext --location westeurope
# Create an Azure storage account omitting location and resource group.
az storage account create \
--name sa1localcontext \
--sku Standard_LRS
# Create a serverless function app in the resource group omitting storage account and resource group.
az functionapp create \
--name FAlocalContext \
--consumption-plan-location westeurope \
--functions-version 2
# See the stored parameter values
az config param-persist show```
<https://learn.microsoft.com/en-us/cli/azure/param-persist-howto>
## How to use Fiddler (web proxy) with the CLI?
```bash
export HTTP_PROXY="http://localhost:8888" HTTPS_PROXY="http://localhost:8888"
export AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1
az login
az account list
az account set -s <subscription>
az configure --defaults location=<location_name>
az configure --defaults group=<resourceGroupName>
Set an environment variable VAULT_NAME to your the name of your Key Vault resource,e.g.:
set VAULT_NAME=pvb-uat-euw-kv
Then run these commands:
del %VAULT_NAME%.csv
for /f %i in ('az keyvault secret list --vault-name %VAULT_NAME%') do @az keyvault secret show --vault-name %VAULT_NAME% --name %i -o tsv --query "{name:name, value:value}" >> %VAULT_NAME%.csv
more %VAULT_NAME%.csv
az webapp list [-g group] [-s sub]
set APP_NAME=pvb-live-euw-admin-as
az webapp config appsettings list -g pvb-live -n %APP_NAME% -o tsv > %APP_NAME%.settings.csv
az functionapp config appsettings list -g pvb-live -n pvb-live-euw-admin-as
set RG=pvb-uat
for /f %i in ('az webapp list -g %RG%' -o tsv --query "[].{name:name}"') do @az webapp config appsettings list -g %RG% -n %i -o tsv >> %RG%.%i.settings.csv
az account set -s Playground
RG=pvb-uat
az resource list -g $RG --query "[].{ name: name, kind: kind, type: type, location: location }" --output table
az account set -s Playground
RG=pvb-uat
az role assignment list --resource-group $RG --output json --query '[].{principalName:principalName, roleDefinitionName:roleDefinitionName, scope:scope}'
az account set -s Playground
RG=pvb-uat
# NB bash on Windows (WSL) may need the CR trimming:
# for scope in "$(az resource list -g $1 -o tsv --query '[].{ id: id }' | tr -d '\r')"; do
for scope in "$(az resource list -g $RG -o tsv --query '[].{ id: id }')"; do
echo IAM for $scope
az role assignment list --scope $scope -o table
done
for rg in $(az group list -o tsv --query "[].{name:name}" | tr -d '\r'); do
#echo resources in $rg
for scope in "$(az resource list -g $rg -o tsv --query '[].{ id: id }' | tr -d '\r')"; do
echo "$scope"
az role assignment list --scope "$scope" -o table
done
done
You can list all your Cosmos DBs in a subscription with something like this:
az cosmosdb list --subscription %subscriptionId% --query "[].{name:name, kind:kind, location:location, resourceGroup:resourceGroup}"
Given all your subscriptions IDs are:
az account list -o tsv --query "[].{id:id}"
Then all your "Cosmoses" can be queried like so:
for /f %s in ('az account list -o tsv --query "[].{id:id}"') do @az cosmosdb list --subscription %s --query "[].{name:name, kind:kind, location:location, resourceGroup:resourceGroup}" -o tsv
* In these examples, the type is "MongoDB". You could remove that ?kind=='MongoDB'
filter from the query and list all as above.
for /f %s in ('az account list -o tsv --query "[].{id:id}"') do @az cosmosdb list --subscription %s --query "[?kind=='MongoDB'].{name:name, kind:kind, location:location, resourceGroup:resourceGroup}" -o json
for sub in $(az account list -o tsv --query '[].{id:id}' | tr -d '\r'); do
az cosmosdb list --subscription $sub --query "[?kind=='MongoDB'].{name:name, kind:kind, location:location, resourceGroup:resourceGroup}" -o json
done
for sub in $(az account list -o tsv --query '[].{id:id}' | tr -d '\r'); do
for sql in $(az sql server list --subscription $sub --query "[].{name:name}" | tr -d '\r'); do
echo $sql
# az sql elastic-pool list --subscription $sub -o table
done
done
$ az webapp deployment source config-zip -g pvb-qat-rg -n pvb-qat-euw-myapp-as --src .\bin\Release\netcoreapp3.1\publish.zip
Getting scm site credentials for zip deployment
Starting zip deployment. This operation can take a while to complete ...
Deployment endpoint responded with status code 202
Active Author Author_email Complete Deployer End_time Is_readonly Is_temp Last_success_end_time Log_url Message Progress Received_time Site_name Start_time Status Status_text Url
-------- -------- -------------- ---------- ---------- ---------------------------- ------------- --------- ---------------------------- ---------------------------------------------------------------------------------- ----------------------------- ---------- -------------------------- ------------------------- ---------------------------- -------- ------------- ------------------------------------------------------------------------------
True N/A N/A True ZipDeploy 2021-01-30T11:53:11.3202611Z True False 2021-01-30T11:53:11.3202611Z https://pvb-qat-euw-myapp-as.scm.azurewebsites.net/api/deployments/latest/log Created via a push deployment 2021-01-30T11:53:09.85145Z pvb-qat-euw-myapp-as 2021-01-30T11:53:10.3827205Z 4 https://pvb-qat-euw-myapp-as.scm.azurewebsites.net/api/deployments/latest
$
az monitor metrics alert create -n "InfoCapchaSqlDtuOver80pct" -g "pvb-qat-rg" --scopes "dtu_used" --condition "avg Percentage DTU > 80" --description "Check to see if the Avg DTU exceeds 80%."
for group in "$(az group list -o tsv --query '[].{name:name}' | tr -d '\r')"; do
az monitor metrics alert list -g $group;
done