Home › Studies › AI-200 › CLI & PowerShell Commands

CLI & PowerShell Commands

AI-200 tasks with the Azure CLI and PowerShell side by side for each domain, copied from the topic pages.

Every command here comes from a CLI or PowerShell table on one of the AI-200 topic pages. A - means the topic page gives no command for that tool. Placeholders such as <rg> are yours to fill in.

Develop containerized solutions on Azure (20–25%)

Container Registry & App Service

TaskAzure CLIPowerShell
Create a Basic registryaz acr create --resource-group myResourceGroup --name mycontainerregistry008 --sku Basic-
Sign in to a registryaz acr login --name myregistry-
Get a token when no Docker daemon runsaz acr login --name <acrName> --expose-token-
Enable the admin useraz acr update -n <acrName> --admin-enabled true-
Alias an image for your registrydocker tag nginx myregistry.azurecr.io/samples/nginx-
Push an imagedocker push myregistry.azurecr.io/samples/nginx-
Build and push in Azure (quick task)az acr build --image sample/hello-world:v1 --registry mycontainerregistry008 --file Dockerfile .-
Run a YAML taskaz acr run --registry <acrName> -f build-push-hello-world.yaml https://github.com/Azure-Samples/acr-tasks.git-
Delete an image by tagaz acr repository delete --name myregistry --image acr-helloworld:latest-
Set a retention policyaz acr config retention update --registry myregistry --status enabled --days 30 --type UntaggedManifests-
Set the app portaz webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITES_PORT=8000-
Grant a web app's identity pull accessaz role assignment create --assignee <principal-id> --scope <registry-resource-id> --role "AcrPull"-
Use managed identity for registry pullsaz webapp config set --resource-group <group-name> --name <app-name> --generic-configurations '{"acrUseManagedIdentityCreds": true}'-
Enable persistent storage (Linux)az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITES_ENABLE_APP_SERVICE_STORAGE=true-

Container Apps & KEDA

TaskAzure CLIPowerShell
Update an app (new image)az containerapp update --name <APPLICATION_NAME> --resource-group <RESOURCE_GROUP_NAME> --image <IMAGE_NAME>-
List revisionsaz containerapp revision list --name <APPLICATION_NAME> --resource-group <RESOURCE_GROUP_NAME> -o table-
Copy a revisionaz containerapp revision copy --name <APPLICATION_NAME> --resource-group <RESOURCE_GROUP_NAME> --cpu 0.75 --memory 1.5Gi-
Activate a revisionaz containerapp revision activate --revision <REVISION_NAME> --resource-group <RESOURCE_GROUP_NAME>-
Deactivate a revisionaz containerapp revision deactivate --revision <REVISION_NAME> --resource-group <RESOURCE_GROUP_NAME>-
Restart a revisionaz containerapp revision restart --revision <REVISION_NAME> --resource-group <RESOURCE_GROUP_NAME>-
Set the revision modeaz containerapp revision set-mode --name <APPLICATION_NAME> --resource-group <RESOURCE_GROUP_NAME> --mode <REVISION_MODE>-
Add a revision labelaz containerapp revision label add --revision <REVISION_NAME> --resource-group <RESOURCE_GROUP_NAME> --label <LABEL_NAME>-
Split traffic by revisionaz containerapp ingress traffic set --name <APP_NAME> --resource-group <RESOURCE_GROUP> --revision-weight <REVISION_1>=50 <REVISION_2>=50-
Split traffic by labelaz containerapp ingress traffic set --name <APP_NAME> --resource-group <RESOURCE_GROUP> --label-weight <LABEL_1>=80 <LABEL_2>=20-
Reference a secret in an environment variableaz containerapp update -n <APP NAME> -g <RESOURCE_GROUP_NAME> --set-env-vars <VAR_NAME>=secretref:<SECRET_NAME>-

AKS Deployments & Troubleshooting

TaskAzure CLIPowerShell
Download credentials and configure kubectlaz aks get-credentials --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME-
Add a user mode node poolaz aks nodepool add --resource-group $RESOURCE_GROUP --cluster-name $CLUSTER_NAME --name $USER_NP --node-count 1 --mode User-
Deploy a manifestkubectl apply -f aks-store-quickstart.yaml-
Verify pods run on a user node poolkubectl get pods -o wide-
Scale pods manuallykubectl scale --replicas=5 deployment.apps/store-front-
Scale nodes manuallyaz aks scale --resource-group myResourceGroup --name myAKSCluster --node-count 5-
Check the autoscalerkubectl get hpa-
List all eventskubectl get events-
List events in one namespacekubectl get events --namespace default-
Check node conditions and eventskubectl describe node my-aks-node-

Topic pages: Container Registry & App Service, Container Apps & KEDA, AKS Deployments & Troubleshooting.

Develop AI solutions by using Azure data management services (25–30%)

Cosmos DB for NoSQL & Vectors

TaskAzure CLIPowerShell
Enable NoSQL vector search on an accountaz cosmosdb update --resource-group <resource-group-name> --name <account-name> --capabilities EnableNoSQLVectorSearch-

PostgreSQL & pgvector

TaskAzure CLIPowerShell
Allowlist an extensionaz postgres flexible-server parameter set --resource-group <resource_group> --server-name <server> --name azure.extensions --value "<extension_name>,<extension_name>"SHOW azure.extensions;
Install pgvector in a database-CREATE EXTENSION vector;
Install DiskANN with its dependency-CREATE EXTENSION IF NOT EXISTS pg_diskann CASCADE;
Connect with psycopg-conn = psycopg.connect(conn_string)
Insert with parameters-cursor.execute("INSERT INTO inventory (name, quantity) VALUES (%s, %s);", ("banana", 150))
Add an embedding column-ALTER TABLE recipes ADD COLUMN embedding vector(1536);
Create an IVFFlat cosine index-CREATE INDEX t_test_embedding_cosine_idx ON t_test USING ivfflat (embedding vector_cosine_ops) WITH (lists = 5000);
Set IVFFlat probes-SET ivfflat.probes = 10;
Set HNSW candidate list for search-SET hnsw.ef_search = 100;
Force a DiskANN index scan-SET LOCAL enable_seqscan TO OFF;
Make a full-disk server writable-SET SESSION CHARACTERISTICS AS TRANSACTION READ WRITE;

Topic pages: Cosmos DB for NoSQL & Vectors, PostgreSQL & pgvector.

Connect to and consume Azure services (20–25%)

Service Bus & Event Grid

TaskAzure CLIPowerShell
Register the Event Grid provideraz provider register --namespace Microsoft.EventGrid-
Create a custom topicaz eventgrid topic create --name $topicname -l westus2 -g gridResourceGroup-
Get a custom topic keyaz eventgrid topic key list --name $topicname -g gridResourceGroup --query "key1" --output tsv-
Post a custom eventcurl -X POST -H "aeg-sas-key: $key" -d "$event" $endpoint-
Send one Service Bus message-await sender.send_messages(message)
Get a Service Bus queue receiver-receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME)
Receive messages-received_msgs = await receiver.receive_messages(max_wait_time=5, max_message_count=20)
Complete a message-await receiver.complete_message(msg)

Azure Functions

TaskAzure CLIPowerShell
Start the local runtimefunc start-
Publish a project with Core Toolsfunc azure functionapp publish <APP_NAME>-
Zip deploy with Azure CLIaz functionapp deployment source config-zip-
Create an app from a custom containeraz functionapp create --image <container>-
Sync triggers by calling the management APIaz rest --method post --url https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.Web/sites/<APP_NAME>/syncfunctiontriggers?api-version=2016-08-01-
Update an app created before August 1, 2019 so remote build worksaz functionapp update --resource-group <RESOURCE_GROUP_NAME> --name <APP_NAME>-
HTTP trigger, anonymous (Python v2)-@app.route(route="hello", auth_level=func.AuthLevel.ANONYMOUS)
Queue output binding (Python v2)-@app.queue_output(arg_name="msg", queue_name="outqueue", connection="AzureWebJobsStorage")
Read an app setting in Python-setting_value = os.getenv("myAppSetting", "default_value")

Topic pages: Service Bus & Event Grid, Azure Functions.

Secure, monitor, and troubleshoot Azure solutions (20–25%)

Key Vault & App Configuration

TaskAzure CLIPowerShell
Create a vault with RBAC and purge protectionaz keyvault create --name "<vault-name>" --resource-group "myResourceGroup" --enable-rbac-authorization true --enable-purge-protection true-
Create a secretaz keyvault secret set --vault-name "<vault-name>" --name "ExamplePassword" --value "hVFkk965BuUv"-
Show a secret valueaz keyvault secret show --name "ExamplePassword" --vault-name "<vault-name>" --query "value"-
Set a key rotation policy from a fileaz keyvault key rotation-policy update --vault-name <vault-name> --name <key-name> --value </path/to/policy.json>-
Rotate a key nowaz keyvault key rotate --vault-name <vault-name> --name <key-name>-
Install the Microsoft Entra identity library (Python)-pip install azure-identity
Install the Key Vault secrets library (Python)-pip install azure-keyvault-secrets
Create a secret client (Python)-client = SecretClient(vault_url=KVUri, credential=credential)
Read a secret (Python)-retrieved_secret = client.get_secret(secretName)
Install the App Configuration provider (Python)-pip install azure-appconfiguration-provider
Load settings with Microsoft Entra ID (Python)-config = load(endpoint=endpoint, credential=credential)
Filter keys and labels (Python)-selects = {SettingSelector(key_filter="message*", label_filter="\0")}

OpenTelemetry & KQL

TaskAzure CLIPowerShell
Install the Python distropip install microsoft-opentelemetry-
Set the connection string for productionexport APPLICATIONINSIGHTS_CONNECTION_STRING="<ConnectionString>"-
Keep about 10% of tracesexport OTEL_TRACES_SAMPLER="microsoft.fixed_percentage" export OTEL_TRACES_SAMPLER_ARG=0.1-
Limit to about 1.5 traces per secondexport OTEL_TRACES_SAMPLER="microsoft.rate_limited" export OTEL_TRACES_SAMPLER_ARG=1.5-
Custom span (Python)-with tracer.start_as_current_span("hello") as span:
Latest 10 rows (KQL)-SecurityEvent | top 10 by TimeGenerated
Count per group (KQL)-Perf | where TimeGenerated > ago(1h) | summarize count() by ObjectName
Hourly average (KQL)-Perf | where TimeGenerated > ago(7d) | where Computer == "DC01.na.contosohotels.com" | where CounterName == "Available MBytes" | summarize avg(CounterValue) by bin(TimeGenerated, 1h)

Topic pages: Key Vault & App Configuration, OpenTelemetry & KQL.

Pages with no command table

These topic pages have no CLI or PowerShell table, so nothing from them is repeated here: Azure Managed Redis.