Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Deploy, evaluate, and manage AI agents end-to-end on Microsoft Azure AI Foundry
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
resource/create/references/patterns.md
1# Common Patterns: Create Foundry Resource23**Table of Contents:** [Pattern A: Quick Setup](#pattern-a-quick-setup) · [Pattern B: Multi-Region Setup](#pattern-b-multi-region-setup) · [Quick Commands Reference](#quick-commands-reference)45## Pattern A: Quick Setup67Complete setup in one go:89```bash10# Ask user: "Use existing resource group or create new?"1112# ==== If user chooses "Use existing" ====13# Count and list existing resource groups14TOTAL_RG_COUNT=$(az group list --query "length([])" -o tsv)15az group list --query "[-5:].{Name:name, Location:location}" --out table1617# Based on count: show appropriate list and options18# User selects resource group19RG="<selected-rg-name>"2021# Fetch details to verify22az group show --name $RG --query "{Name:name, Location:location, State:properties.provisioningState}"23# Then skip to creating Foundry resource below2425# ==== If user chooses "Create new" ====26# List regions and ask user to choose27az account list-locations --query "[].{Region:name}" --out table2829# Variables30RG="rg-ai-services" # New resource group name31LOCATION="westus2" # User's chosen location32RESOURCE_NAME="my-foundry-resource"3334# Create new resource group35az group create --name $RG --location $LOCATION3637# Verify creation38az group show --name $RG --query "{Name:name, Location:location, State:properties.provisioningState}"3940# Create Foundry resource in user's chosen location41az cognitiveservices account create \42--name $RESOURCE_NAME \43--resource-group $RG \44--kind AIServices \45--sku S0 \46--location $LOCATION \47--yes4849# Get endpoint and keys50echo "Resource created successfully!"51az cognitiveservices account show \52--name $RESOURCE_NAME \53--resource-group $RG \54--query "{Endpoint:properties.endpoint, Location:location}"5556az cognitiveservices account keys list \57--name $RESOURCE_NAME \58--resource-group $RG59```6061## Pattern B: Multi-Region Setup6263Create resources in multiple regions:6465```bash66# Variables67RG="rg-ai-services"68REGIONS=("eastus" "westus2" "westeurope")6970# Create resource group71az group create --name $RG --location eastus7273# Create resources in each region74for REGION in "${REGIONS[@]}"; do75RESOURCE_NAME="foundry-${REGION}"76echo "Creating resource in $REGION..."7778az cognitiveservices account create \79--name $RESOURCE_NAME \80--resource-group $RG \81--kind AIServices \82--sku S0 \83--location $REGION \84--yes8586echo "Resource $RESOURCE_NAME created in $REGION"87done8889# List all resources90az cognitiveservices account list --resource-group $RG --output table91```9293## Quick Commands Reference9495```bash96# Count total resource groups to determine which scenario applies97az group list --query "length([])" -o tsv9899# Check existing resource groups (up to 5 most recent)100# 0 → create new | 1-4 → select or create | 5+ → select/other/create101az group list --query "[-5:].{Name:name, Location:location}" --out table102103# If 5+ resource groups exist and user selects "Other", show all104az group list --query "[].{Name:name, Location:location}" --out table105106# If user selects existing resource group, fetch details to verify and get location107az group show --name <selected-rg-name> --query "{Name:name, Location:location, State:properties.provisioningState}"108109# List available regions (for creating new resource group)110az account list-locations --query "[].{Region:name}" --out table111112# Create resource group (if needed)113az group create --name rg-ai-services --location westus2114115# Create Foundry resource116az cognitiveservices account create \117--name my-foundry-resource \118--resource-group rg-ai-services \119--kind AIServices \120--sku S0 \121--location westus2 \122--yes123124# List resources in group125az cognitiveservices account list --resource-group rg-ai-services126127# Get resource details128az cognitiveservices account show \129--name my-foundry-resource \130--resource-group rg-ai-services131132# Delete resource133az cognitiveservices account delete \134--name my-foundry-resource \135--resource-group rg-ai-services136```137