Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build and deploy AI applications on Azure AI Foundry using Microsoft's model catalog and AI services
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
models/deploy-model/preset/references/workflow.md
1# Preset Deployment Workflow — Step-by-Step23Condensed implementation reference for preset (optimal region) model deployment. See [SKILL.md](../SKILL.md) for overview.45**Table of Contents:** [Phase 1: Verify Authentication](#phase-1-verify-authentication) · [Phase 2: Get Current Project](#phase-2-get-current-project) · [Phase 3: Get Model Name](#phase-3-get-model-name) · [Phase 4: Check Current Region Capacity](#phase-4-check-current-region-capacity) · [Phase 5: Query Multi-Region Capacity](#phase-5-query-multi-region-capacity) · [Phase 6: Select Region and Project](#phase-6-select-region-and-project) · [Phase 7: Deploy Model](#phase-7-deploy-model)67---89## Phase 1: Verify Authentication1011```bash12az account show --query "{Subscription:name, User:user.name}" -o table13```1415If not logged in: `az login`1617Switch subscription:1819```bash20az account list --query "[].[name,id,state]" -o table21az account set --subscription <subscription-id>22```2324---2526## Phase 2: Get Current Project2728Read `PROJECT_RESOURCE_ID` from env or prompt user. Format:29`/subscriptions/{sub-id}/resourceGroups/{rg}/providers/Microsoft.CognitiveServices/accounts/{account}/projects/{project}`3031Parse ARM ID components:3233```bash34SUBSCRIPTION_ID=$(echo "$PROJECT_RESOURCE_ID" | sed -n 's|.*/subscriptions/\([^/]*\).*|\1|p')35RESOURCE_GROUP=$(echo "$PROJECT_RESOURCE_ID" | sed -n 's|.*/resourceGroups/\([^/]*\).*|\1|p')36ACCOUNT_NAME=$(echo "$PROJECT_RESOURCE_ID" | sed -n 's|.*/accounts/\([^/]*\)/projects.*|\1|p')37PROJECT_NAME=$(echo "$PROJECT_RESOURCE_ID" | sed -n 's|.*/projects/\([^/?]*\).*|\1|p')38```3940Verify project exists and get region:4142```bash43az account set --subscription "$SUBSCRIPTION_ID"4445PROJECT_REGION=$(az cognitiveservices account show \46--name "$PROJECT_NAME" \47--resource-group "$RESOURCE_GROUP" \48--query location -o tsv)49```5051---5253## Phase 3: Get Model Name5455If model not provided as parameter, list available models:5657```bash58az cognitiveservices account list-models \59--name "$PROJECT_NAME" \60--resource-group "$RESOURCE_GROUP" \61--query "[].name" -o tsv | sort -u62```6364Get versions for selected model:6566```bash67az cognitiveservices account list-models \68--name "$PROJECT_NAME" \69--resource-group "$RESOURCE_GROUP" \70--query "[?name=='$MODEL_NAME'].{Name:name, Version:version, Format:format}" \71-o table72```7374---7576## Phase 4: Check Current Region Capacity7778```bash79CAPACITY_JSON=$(az rest --method GET \80--url "https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/providers/Microsoft.CognitiveServices/locations/$PROJECT_REGION/modelCapacities?api-version=2024-10-01&modelFormat=OpenAI&modelName=$MODEL_NAME&modelVersion=$MODEL_VERSION")8182CURRENT_CAPACITY=$(echo "$CAPACITY_JSON" | jq -r '.value[] | select(.properties.skuName=="GlobalStandard") | .properties.availableCapacity')83```8485If `CURRENT_CAPACITY > 0` → skip to Phase 7. Otherwise continue to Phase 5.8687---8889## Phase 5: Query Multi-Region Capacity9091```bash92ALL_REGIONS_JSON=$(az rest --method GET \93--url "https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/providers/Microsoft.CognitiveServices/modelCapacities?api-version=2024-10-01&modelFormat=OpenAI&modelName=$MODEL_NAME&modelVersion=$MODEL_VERSION")94```9596Extract available regions (capacity > 0):9798```bash99AVAILABLE_REGIONS=$(echo "$ALL_REGIONS_JSON" | jq -r '.value[] | select(.properties.skuName=="GlobalStandard" and .properties.availableCapacity > 0) | "\(.location)|\(.properties.availableCapacity)"')100```101102Extract unavailable regions:103104```bash105UNAVAILABLE_REGIONS=$(echo "$ALL_REGIONS_JSON" | jq -r '.value[] | select(.properties.skuName=="GlobalStandard" and (.properties.availableCapacity == 0 or .properties.availableCapacity == null)) | "\(.location)|0"')106```107108If no regions have capacity, defer to the [quota skill](../../../../quota/quota.md) for increase requests. Suggest checking existing deployments or trying alternative models like `gpt-4o-mini`.109110---111112## Phase 6: Select Region and Project113114Present available regions to user. Store selection as `SELECTED_REGION`.115116Find projects in selected region:117118```bash119PROJECTS_IN_REGION=$(az cognitiveservices account list \120--query "[?kind=='AIProject' && location=='$SELECTED_REGION'].{Name:name, ResourceGroup:resourceGroup}" \121--output json)122```123124**If no projects exist — create new:**125126```bash127az cognitiveservices account create \128--name "$HUB_NAME" \129--resource-group "$RESOURCE_GROUP" \130--location "$SELECTED_REGION" \131--kind "AIServices" \132--sku "S0" --yes133134az cognitiveservices account create \135--name "$NEW_PROJECT_NAME" \136--resource-group "$RESOURCE_GROUP" \137--location "$SELECTED_REGION" \138--kind "AIProject" \139--sku "S0" --yes140```141142---143144## Phase 7: Deploy Model145146Generate unique deployment name using `scripts/generate_deployment_name.sh`:147148```bash149DEPLOYMENT_NAME=$(bash scripts/generate_deployment_name.sh "$ACCOUNT_NAME" "$RESOURCE_GROUP" "$MODEL_NAME")150```151152Calculate capacity — 50% of available, minimum 50 TPM:153154```bash155SELECTED_CAPACITY=$(echo "$ALL_REGIONS_JSON" | jq -r ".value[] | select(.location==\"$SELECTED_REGION\" and .properties.skuName==\"GlobalStandard\") | .properties.availableCapacity")156DEPLOY_CAPACITY=$(( SELECTED_CAPACITY / 2 ))157[ "$DEPLOY_CAPACITY" -lt 50 ] && DEPLOY_CAPACITY=50158```159160Create deployment:161162```bash163az cognitiveservices account deployment create \164--name "$ACCOUNT_NAME" \165--resource-group "$RESOURCE_GROUP" \166--deployment-name "$DEPLOYMENT_NAME" \167--model-name "$MODEL_NAME" \168--model-version "$MODEL_VERSION" \169--model-format "OpenAI" \170--sku-name "GlobalStandard" \171--sku-capacity "$DEPLOY_CAPACITY"172```173174Monitor with `az cognitiveservices account deployment show ... --query "properties.provisioningState"` until `Succeeded` or `Failed`.175