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.
models/deploy-model/customize/references/customize-workflow.md
1# Customize Workflow โ Detailed Phase Instructions23> Reference for: `models/deploy-model/customize/SKILL.md`45## Phase 1: Verify Authentication67```bash8az account show --query "{Subscription:name, User:user.name}" -o table9```1011If not logged in: `az login`1213Set subscription if needed:14```bash15az account list --query "[].[name,id,state]" -o table16az account set --subscription <subscription-id>17```1819---2021## Phase 2: Get Project Resource ID2223Check `PROJECT_RESOURCE_ID` env var. If not set, prompt user.2425**Format:** `/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.CognitiveServices/accounts/{account}/projects/{project}`2627---2829## Phase 3: Parse and Verify Project3031Parse ARM resource ID to extract components:3233```powershell34$SUBSCRIPTION_ID = ($PROJECT_RESOURCE_ID -split '/')[2]35$RESOURCE_GROUP = ($PROJECT_RESOURCE_ID -split '/')[4]36$ACCOUNT_NAME = ($PROJECT_RESOURCE_ID -split '/')[8]37$PROJECT_NAME = ($PROJECT_RESOURCE_ID -split '/')[10]38```3940Verify project exists and get region:41```bash42az account set --subscription $SUBSCRIPTION_ID43az cognitiveservices account show \44--name $ACCOUNT_NAME \45--resource-group $RESOURCE_GROUP \46--query location -o tsv47```4849---5051## Phase 4: Get Model Name5253List available models if not provided:54```bash55az cognitiveservices account list-models \56--name $ACCOUNT_NAME \57--resource-group $RESOURCE_GROUP \58--query "[].name" -o json59```6061Present sorted unique list. Allow custom model name entry.6263**Detect model format:**6465```bash66# Get model format (e.g., OpenAI, Anthropic, Meta-Llama, Mistral, Cohere)67MODEL_FORMAT=$(az cognitiveservices account list-models \68--name "$ACCOUNT_NAME" \69--resource-group "$RESOURCE_GROUP" \70--query "[?name=='$MODEL_NAME'].format" -o tsv | head -1)7172MODEL_FORMAT=${MODEL_FORMAT:-"OpenAI"}73echo "Model format: $MODEL_FORMAT"74```7576> ๐ก **Model format determines the deployment path:**77> - `OpenAI` โ Standard CLI, TPM-based capacity, RAI policies, version upgrade policies78> - `Anthropic` โ REST API with `modelProviderData`, capacity=1, no RAI, no version upgrade79> - All other formats (`Meta-Llama`, `Mistral`, `Cohere`, etc.) โ Standard CLI, capacity=1 (MaaS), no RAI, no version upgrade8081---8283## Phase 5: List and Select Model Version8485```bash86az cognitiveservices account list-models \87--name $ACCOUNT_NAME \88--resource-group $RESOURCE_GROUP \89--query "[?name=='$MODEL_NAME'].version" -o json90```9192Recommend latest version (first in list). Default to `"latest"` if no versions found.9394---9596## Phase 6: List and Select SKU9798> โ ๏ธ **Warning:** Never hardcode SKU lists โ always query live data.99100**Step A โ Query model-supported SKUs:**101```bash102az cognitiveservices model list \103--location $PROJECT_REGION \104--subscription $SUBSCRIPTION_ID -o json105```106107Filter: `model.name == $MODEL_NAME && model.version == $MODEL_VERSION`, extract `model.skus[].name`.108109**Step B โ Check subscription quota per SKU:**110```bash111az cognitiveservices usage list \112--location $PROJECT_REGION \113--subscription $SUBSCRIPTION_ID -o json114```115116Quota key pattern: `OpenAI.<SKU>.<model-name>`. Calculate `available = limit - currentValue`.117118**Step C โ Present only deployable SKUs** (available > 0). If no SKUs have quota, direct user to the [quota skill](../../../../quota/quota.md).119120---121122## Phase 7: Configure Capacity123124> โ ๏ธ **Non-OpenAI models (MaaS):** If `MODEL_FORMAT != "OpenAI"`, capacity is always `1` (pay-per-token billing). Skip capacity configuration and set `DEPLOY_CAPACITY=1`. Proceed to Phase 7c (Anthropic) or Phase 8.125126**For OpenAI models only โ query capacity via REST API:**127```bash128# Current region capacity129az rest --method GET --url \130"https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/providers/Microsoft.CognitiveServices/locations/$PROJECT_REGION/modelCapacities?api-version=2024-10-01&modelFormat=$MODEL_FORMAT&modelName=$MODEL_NAME&modelVersion=$MODEL_VERSION"131```132133Filter result for `properties.skuName == $SELECTED_SKU`. Read `properties.availableCapacity`.134135**Capacity defaults by SKU (OpenAI only):**136137| SKU | Unit | Min | Max | Step | Default |138|-----|------|-----|-----|------|---------|139| ProvisionedManaged | PTU | 50 | 1000 | 50 | 100 |140| Others (TPM-based) | TPM | 1000 | min(available, 300000) | 1000 | min(10000, available/2) |141142Validate user input: must be >= min, <= max, multiple of step. On invalid input, explain constraints.143144### Phase 7b: Cross-Region Fallback145146If no capacity in current region, query ALL regions:147```bash148az rest --method GET --url \149"https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/providers/Microsoft.CognitiveServices/modelCapacities?api-version=2024-10-01&modelFormat=$MODEL_FORMAT&modelName=$MODEL_NAME&modelVersion=$MODEL_VERSION"150```151152Filter: `properties.skuName == $SELECTED_SKU && properties.availableCapacity > 0`. Sort descending by capacity.153154Present available regions. After user selects region, find existing projects there:155```bash156az cognitiveservices account list \157--query "[?kind=='AIProject' && location=='$PROJECT_REGION'].{Name:name, ResourceGroup:resourceGroup}" \158-o json159```160161If projects exist, let user select one and update `$ACCOUNT_NAME`, `$RESOURCE_GROUP`. If none, direct to project/create skill.162163Re-run capacity configuration with new region's available capacity.164165If no region has capacity: fail with guidance to request quota increase, check existing deployments, or try different model/SKU.166167---168169## Phase 7c: Anthropic Model Provider Data (Anthropic models only)170171> โ ๏ธ **Only execute this phase if `MODEL_FORMAT == "Anthropic"`.** For OpenAI and other models, skip to Phase 8.172173Anthropic models require `modelProviderData` in the deployment payload. Collect this before deployment.174175**Step 1: Prompt user to select industry**176177Present the following list and ask the user to choose one:178179```1801. None (API value: none)1812. Biotechnology (API value: biotechnology)1823. Consulting (API value: consulting)1834. Education (API value: education)1845. Finance (API value: finance)1856. Food & Beverage (API value: food_and_beverage)1867. Government (API value: government)1878. Healthcare (API value: healthcare)1889. Insurance (API value: insurance)18910. Law (API value: law)19011. Manufacturing (API value: manufacturing)19112. Media (API value: media)19213. Nonprofit (API value: nonprofit)19314. Technology (API value: technology)19415. Telecommunications (API value: telecommunications)19516. Sport & Recreation (API value: sport_and_recreation)19617. Real Estate (API value: real_estate)19718. Retail (API value: retail)19819. Other (API value: other)199```200201> โ ๏ธ **Do NOT pick a default industry or hardcode a value. Always ask the user.** This is required by Anthropic's terms of service. The industry list is static โ there is no REST API that provides it.202203Store selection as `SELECTED_INDUSTRY` (use the API value, e.g., `technology`).204205**Step 2: Fetch tenant info (country code and organization name)**206207```bash208TENANT_INFO=$(az rest --method GET \209--url "https://management.azure.com/tenants?api-version=2024-11-01" \210--query "value[0].{countryCode:countryCode, displayName:displayName}" -o json)211212COUNTRY_CODE=$(echo "$TENANT_INFO" | jq -r '.countryCode')213ORG_NAME=$(echo "$TENANT_INFO" | jq -r '.displayName')214```215216*PowerShell version:*217```powershell218$tenantInfo = az rest --method GET `219--url "https://management.azure.com/tenants?api-version=2024-11-01" `220--query "value[0].{countryCode:countryCode, displayName:displayName}" -o json | ConvertFrom-Json221222$countryCode = $tenantInfo.countryCode223$orgName = $tenantInfo.displayName224```225226Store `COUNTRY_CODE` and `ORG_NAME` for use in Phase 13.227228---229230## Phase 8: Select RAI Policy (Content Filter)231232> โ ๏ธ **Note:** RAI policies only apply to OpenAI models. Skip this phase if `MODEL_FORMAT != "OpenAI"` (Anthropic, Meta-Llama, Mistral, Cohere, etc. do not use RAI policies).233234Present options:2351. `Microsoft.DefaultV2` โ Balanced filtering (recommended). Filters hate, violence, sexual, self-harm.2362. `Microsoft.Prompt-Shield` โ Enhanced prompt injection/jailbreak protection.2373. Custom policies โ Organization-specific (configured in Azure Portal).238239Default: `Microsoft.DefaultV2`.240241---242243## Phase 9: Configure Advanced Options244245Options are SKU-dependent:246247**A. Dynamic Quota** (GlobalStandard only)248- Auto-scales beyond base allocation when capacity available249- Default: enabled250251**B. Priority Processing** (ProvisionedManaged only)252- Prioritizes requests during high load; additional charges apply253- Default: disabled254255**C. Spillover** (any SKU)256- Redirects requests to backup deployment at capacity257- Requires existing deployment; list with:258```bash259az cognitiveservices account deployment list \260--name $ACCOUNT_NAME \261--resource-group $RESOURCE_GROUP \262--query "[].name" -o json263```264- Default: disabled265266---267268## Phase 10: Configure Version Upgrade Policy269270> โ ๏ธ **Note:** Version upgrade policies only apply to OpenAI models. Skip this phase if `MODEL_FORMAT != "OpenAI"`.271272| Policy | Description |273|--------|-------------|274| `OnceNewDefaultVersionAvailable` | Auto-upgrade to new default (Recommended) |275| `OnceCurrentVersionExpired` | Upgrade only when current expires |276| `NoAutoUpgrade` | Manual upgrade only |277278Default: `OnceNewDefaultVersionAvailable`.279280---281282## Phase 11: Generate Deployment Name283284List existing deployments to avoid conflicts:285```bash286az cognitiveservices account deployment list \287--name $ACCOUNT_NAME \288--resource-group $RESOURCE_GROUP \289--query "[].name" -o json290```291292Auto-generate: use model name as base, append `-2`, `-3` etc. if taken. Allow custom override. Validate: `^[\w.-]{2,64}$`.293294---295296## Phase 12: Review Configuration297298Display summary of all selections for user confirmation before proceeding:299- Model, version, deployment name300- SKU, capacity (with unit), region301- RAI policy, version upgrade policy302- Advanced options (dynamic quota, priority, spillover)303- Account, resource group, project304305User confirms or cancels.306307---308309## Phase 13: Execute Deployment310311> ๐ก `MODEL_FORMAT` was already detected in Phase 4. Use the stored value here.312313### Standard CLI deployment (non-Anthropic models):314315**Create deployment:**316```bash317az cognitiveservices account deployment create \318--name $ACCOUNT_NAME \319--resource-group $RESOURCE_GROUP \320--deployment-name $DEPLOYMENT_NAME \321--model-name $MODEL_NAME \322--model-version $MODEL_VERSION \323--model-format "$MODEL_FORMAT" \324--sku-name $SELECTED_SKU \325--sku-capacity $DEPLOY_CAPACITY326```327328> ๐ก **Note:** For non-OpenAI MaaS models, `$DEPLOY_CAPACITY` is `1` (set in Phase 7).329330### Anthropic model deployment (requires modelProviderData):331332The Azure CLI does not support `--model-provider-data`. Use the ARM REST API directly.333334> โ ๏ธ Industry, country code, and organization name should have been collected in Phase 7c.335336```bash337echo "Creating Anthropic model deployment via REST API..."338339az rest --method PUT \340--url "https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.CognitiveServices/accounts/$ACCOUNT_NAME/deployments/$DEPLOYMENT_NAME?api-version=2024-10-01" \341--body "{342\"sku\": {343\"name\": \"$SELECTED_SKU\",344\"capacity\": 1345},346\"properties\": {347\"model\": {348\"format\": \"Anthropic\",349\"name\": \"$MODEL_NAME\",350\"version\": \"$MODEL_VERSION\"351},352\"modelProviderData\": {353\"industry\": \"$SELECTED_INDUSTRY\",354\"countryCode\": \"$COUNTRY_CODE\",355\"organizationName\": \"$ORG_NAME\"356}357}358}"359```360361*PowerShell version:*362```powershell363Write-Host "Creating Anthropic model deployment via REST API..."364365$body = @{366sku = @{367name = $SELECTED_SKU368capacity = 1369}370properties = @{371model = @{372format = "Anthropic"373name = $MODEL_NAME374version = $MODEL_VERSION375}376modelProviderData = @{377industry = $SELECTED_INDUSTRY378countryCode = $countryCode379organizationName = $orgName380}381}382} | ConvertTo-Json -Depth 5383384az rest --method PUT `385--url "https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.CognitiveServices/accounts/$ACCOUNT_NAME/deployments/${DEPLOYMENT_NAME}?api-version=2024-10-01" `386--body $body387```388389> ๐ก **Note:** Anthropic models use `capacity: 1` (MaaS billing model), not TPM-based capacity. RAI policy is not applicable for Anthropic models.390391### Monitor deployment status:392```bash393az cognitiveservices account deployment show \394--name $ACCOUNT_NAME \395--resource-group $RESOURCE_GROUP \396--deployment-name $DEPLOYMENT_NAME \397--query "properties.provisioningState" -o tsv398```399400Poll until `Succeeded` or `Failed`. Timeout after 5 minutes.401402**Get endpoint:**403```bash404az cognitiveservices account show \405--name $ACCOUNT_NAME \406--resource-group $RESOURCE_GROUP \407--query "properties.endpoint" -o tsv408```409410On success, display deployment name, model, version, SKU, capacity, region, RAI policy, rate limits, endpoint, and Azure AI Foundry portal link.411