Detailed Workflows: Create Foundry Resource
Table of Contents: Workflow 1: Create Resource Group · Workflow 2: Create Foundry Resource · Workflow 3: Register Resource Provider
Workflow 1: Create Resource Group - Detailed Steps
Step 1: Ask user preference
Ask the user which option they prefer:
- Use an existing resource group
- Create a new resource group
Step 2a: If user chooses "Use existing resource group"
Count and list existing resource groups:
# Count total resource groups
TOTAL_RG_COUNT=$(az group list --query "length([])" -o tsv)
# Get list of resource groups (up to 5 most recent)
az group list --query "[-5:].{Name:name, Location:location}" --out tableHandle based on count:
If 0 resources found:
- Inform user: "No existing resource groups found"
- Ask if they want to create a new one, then proceed to Step 2b
If 1-4 resources found:
- Display all X resource groups to the user
- Let user select from the list
- Fetch the selected resource group details:
az group show --name <selected-rg-name> --query "{Name:name, Location:location, State:properties.provisioningState}"- Display details to user, then proceed to create Foundry resource
If 5+ resources found:
- Display the 5 most recent resource groups
- Present options:
- Select from the 5 displayed
- Other (see all resource groups)
- If user selects a resource group, fetch details:
az group show --name <selected-rg-name> --query "{Name:name, Location:location, State:properties.provisioningState}"- If user chooses "Other", show all:
az group list --query "[].{Name:name, Location:location}" --out tableThen let user select, and fetch details as above
- Display details to user, then proceed to create Foundry resource
Step 2b: If user chooses "Create new resource group"
- List available Azure regions:
az account list-locations --query "[].{Region:name}" --out tableCommon regions:
eastus,eastus2- US East Coastwestus,westus2,westus3- US West Coastcentralus- US Centralwesteurope,northeurope- Europesoutheastasia,eastasia- Asia Pacific
- Ask user to choose a region from the list above
- Create resource group in the chosen region:
az group create \
--name <resource-group-name> \
--location <user-chosen-location>- Verify creation:
az group show --name <resource-group-name> --query "{Name:name, Location:location, State:properties.provisioningState}"Expected output: State: "Succeeded"
Workflow 2: Create Foundry Resource - Detailed Steps
Step 1: Verify prerequisites
# Check Azure CLI version (need 2.0+)
az --version
# Verify authentication
az account show
# Check resource provider registration status
az provider show --namespace Microsoft.CognitiveServices --query "registrationState"If provider not registered, see Workflow #3: Register Resource Provider.
Step 2: Choose location
Always ask the user to choose a location. List available regions and let the user select:
# List available regions for Cognitive Services
az account list-locations --query "[].{Region:name, DisplayName:displayName}" --out tableCommon regions for AI Services:
eastus,eastus2- US East Coastwestus,westus2,westus3- US West Coastcentralus- US Centralwesteurope,northeurope- Europesoutheastasia,eastasia- Asia Pacific
Important: Do not automatically use the resource group's location. Always ask the user which region they prefer.
Step 3: Create Foundry resource
az cognitiveservices account create \
--name <resource-name> \
--resource-group <rg> \
--kind AIServices \
--sku S0 \
--location <location> \
--yesParameters:
--name: Unique resource name (globally unique across Azure)--resource-group: Existing resource group name--kind: Must beAIServicesfor multi-service resource--sku: Must be S0 (Standard - the only supported tier for AIServices)--location: Azure region (always ask user to choose from available regions)--yes: Auto-accept terms without prompting
Step 4: Verify resource creation
# Check resource details to verify creation
az cognitiveservices account show \
--name <resource-name> \
--resource-group <rg>
# View endpoint and configuration
az cognitiveservices account show \
--name <resource-name> \
--resource-group <rg> \
--query "{Name:name, Endpoint:properties.endpoint, Location:location, Kind:kind, SKU:sku.name}"Expected output:
provisioningState: "Succeeded"- Endpoint URL
- SKU: S0
- Kind: AIServices
Step 5: Get access keys
az cognitiveservices account keys list \
--name <resource-name> \
--resource-group <rg>This returns key1 and key2 for API authentication.
Workflow 3: Register Resource Provider - Detailed Steps
When Needed
Required when:
- First time creating Cognitive Services in subscription
- Error:
ResourceProviderNotRegistered - Insufficient permissions during resource creation
Steps
Step 1: Check registration status
az provider show \
--namespace Microsoft.CognitiveServices \
--query "registrationState"Possible states:
Registered: Ready to useNotRegistered: Needs registrationRegistering: Registration in progress
Step 2: Register provider
az provider register --namespace Microsoft.CognitiveServicesStep 3: Wait for registration
Registration typically takes 1-2 minutes. Check status:
az provider show \
--namespace Microsoft.CognitiveServices \
--query "registrationState"Wait until state is Registered.
Step 4: Verify registration
az provider list --query "[?namespace=='Microsoft.CognitiveServices']"Required Permissions
To register a resource provider, you need one of:
- Subscription Owner role
- Contributor role
- Custom role with
Microsoft.*/register/actionpermission
If you are not the subscription owner:
- Ask someone with the Owner or Contributor role to register the provider for you
- Alternatively, ask them to grant you the
/register/actionprivilege so you can register it yourself
Alternative registration methods:
- Azure CLI (recommended):
az provider register --namespace Microsoft.CognitiveServices - Azure Portal: Navigate to Subscriptions → Resource providers → Microsoft.CognitiveServices → Register
- PowerShell:
Register-AzResourceProvider -ProviderNamespace Microsoft.CognitiveServices