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
| Task | Azure CLI | PowerShell |
|---|
| Create a Basic registry | az acr create --resource-group myResourceGroup --name mycontainerregistry008 --sku Basic | - |
| Sign in to a registry | az acr login --name myregistry | - |
| Get a token when no Docker daemon runs | az acr login --name <acrName> --expose-token | - |
| Enable the admin user | az acr update -n <acrName> --admin-enabled true | - |
| Alias an image for your registry | docker tag nginx myregistry.azurecr.io/samples/nginx | - |
| Push an image | docker 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 task | az acr run --registry <acrName> -f build-push-hello-world.yaml https://github.com/Azure-Samples/acr-tasks.git | - |
| Delete an image by tag | az acr repository delete --name myregistry --image acr-helloworld:latest | - |
| Set a retention policy | az acr config retention update --registry myregistry --status enabled --days 30 --type UntaggedManifests | - |
| Set the app port | az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITES_PORT=8000 | - |
| Grant a web app's identity pull access | az role assignment create --assignee <principal-id> --scope <registry-resource-id> --role "AcrPull" | - |
| Use managed identity for registry pulls | az 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
| Task | Azure CLI | PowerShell |
|---|
| Update an app (new image) | az containerapp update --name <APPLICATION_NAME> --resource-group <RESOURCE_GROUP_NAME> --image <IMAGE_NAME> | - |
| List revisions | az containerapp revision list --name <APPLICATION_NAME> --resource-group <RESOURCE_GROUP_NAME> -o table | - |
| Copy a revision | az containerapp revision copy --name <APPLICATION_NAME> --resource-group <RESOURCE_GROUP_NAME> --cpu 0.75 --memory 1.5Gi | - |
| Activate a revision | az containerapp revision activate --revision <REVISION_NAME> --resource-group <RESOURCE_GROUP_NAME> | - |
| Deactivate a revision | az containerapp revision deactivate --revision <REVISION_NAME> --resource-group <RESOURCE_GROUP_NAME> | - |
| Restart a revision | az containerapp revision restart --revision <REVISION_NAME> --resource-group <RESOURCE_GROUP_NAME> | - |
| Set the revision mode | az containerapp revision set-mode --name <APPLICATION_NAME> --resource-group <RESOURCE_GROUP_NAME> --mode <REVISION_MODE> | - |
| Add a revision label | az containerapp revision label add --revision <REVISION_NAME> --resource-group <RESOURCE_GROUP_NAME> --label <LABEL_NAME> | - |
| Split traffic by revision | az containerapp ingress traffic set --name <APP_NAME> --resource-group <RESOURCE_GROUP> --revision-weight <REVISION_1>=50 <REVISION_2>=50 | - |
| Split traffic by label | az 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 variable | az containerapp update -n <APP NAME> -g <RESOURCE_GROUP_NAME> --set-env-vars <VAR_NAME>=secretref:<SECRET_NAME> | - |
AKS Deployments & Troubleshooting
| Task | Azure CLI | PowerShell |
|---|
| Download credentials and configure kubectl | az aks get-credentials --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME | - |
| Add a user mode node pool | az aks nodepool add --resource-group $RESOURCE_GROUP --cluster-name $CLUSTER_NAME --name $USER_NP --node-count 1 --mode User | - |
| Deploy a manifest | kubectl apply -f aks-store-quickstart.yaml | - |
| Verify pods run on a user node pool | kubectl get pods -o wide | - |
| Scale pods manually | kubectl scale --replicas=5 deployment.apps/store-front | - |
| Scale nodes manually | az aks scale --resource-group myResourceGroup --name myAKSCluster --node-count 5 | - |
| Check the autoscaler | kubectl get hpa | - |
| List all events | kubectl get events | - |
| List events in one namespace | kubectl get events --namespace default | - |
| Check node conditions and events | kubectl 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
| Task | Azure CLI | PowerShell |
|---|
| Enable NoSQL vector search on an account | az cosmosdb update --resource-group <resource-group-name> --name <account-name> --capabilities EnableNoSQLVectorSearch | - |
PostgreSQL & pgvector
| Task | Azure CLI | PowerShell |
|---|
| Allowlist an extension | az 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
| Task | Azure CLI | PowerShell |
|---|
| Register the Event Grid provider | az provider register --namespace Microsoft.EventGrid | - |
| Create a custom topic | az eventgrid topic create --name $topicname -l westus2 -g gridResourceGroup | - |
| Get a custom topic key | az eventgrid topic key list --name $topicname -g gridResourceGroup --query "key1" --output tsv | - |
| Post a custom event | curl -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
| Task | Azure CLI | PowerShell |
|---|
| Start the local runtime | func start | - |
| Publish a project with Core Tools | func azure functionapp publish <APP_NAME> | - |
| Zip deploy with Azure CLI | az functionapp deployment source config-zip | - |
| Create an app from a custom container | az functionapp create --image <container> | - |
| Sync triggers by calling the management API | az 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 works | az 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
| Task | Azure CLI | PowerShell |
|---|
| Create a vault with RBAC and purge protection | az keyvault create --name "<vault-name>" --resource-group "myResourceGroup" --enable-rbac-authorization true --enable-purge-protection true | - |
| Create a secret | az keyvault secret set --vault-name "<vault-name>" --name "ExamplePassword" --value "hVFkk965BuUv" | - |
| Show a secret value | az keyvault secret show --name "ExamplePassword" --vault-name "<vault-name>" --query "value" | - |
| Set a key rotation policy from a file | az keyvault key rotation-policy update --vault-name <vault-name> --name <key-name> --value </path/to/policy.json> | - |
| Rotate a key now | az 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
| Task | Azure CLI | PowerShell |
|---|
| Install the Python distro | pip install microsoft-opentelemetry | - |
| Set the connection string for production | export APPLICATIONINSIGHTS_CONNECTION_STRING="<ConnectionString>" | - |
| Keep about 10% of traces | export OTEL_TRACES_SAMPLER="microsoft.fixed_percentage"
export OTEL_TRACES_SAMPLER_ARG=0.1 | - |
| Limit to about 1.5 traces per second | export 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.