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/scripts/generate_deployment_url.ps1
1# Generate Azure AI Foundry portal URL for a model deployment2# This script creates a direct clickable link to view a deployment in the Azure AI Foundry portal3#4# NOTE: The encoding scheme for the subscription ID portion is proprietary to Azure AI Foundry.5# This script uses a GUID byte encoding approach, but may need adjustment based on the actual encoding used.67param(8[Parameter(Mandatory=$true)]9[string]$SubscriptionId,1011[Parameter(Mandatory=$true)]12[string]$ResourceGroup,1314[Parameter(Mandatory=$true)]15[string]$FoundryResource,1617[Parameter(Mandatory=$true)]18[string]$ProjectName,1920[Parameter(Mandatory=$true)]21[string]$DeploymentName22)2324function Get-SubscriptionIdEncoded {25param([string]$SubscriptionId)2627# Parse GUID and convert to bytes in string order (big-endian)28# Not using ToByteArray() because it uses little-endian format29$guidString = $SubscriptionId.Replace('-', '')30$bytes = New-Object byte[] 1631for ($i = 0; $i -lt 16; $i++) {32$bytes[$i] = [Convert]::ToByte($guidString.Substring($i * 2, 2), 16)33}3435# Encode as base64url36$base64 = [Convert]::ToBase64String($bytes)37$urlSafe = $base64.Replace('+', '-').Replace('/', '_').TrimEnd('=')38return $urlSafe39}4041function Get-FoundryDeploymentUrl {42param(43[string]$SubscriptionId,44[string]$ResourceGroup,45[string]$FoundryResource,46[string]$ProjectName,47[string]$DeploymentName48)4950# Encode subscription ID51$encodedSubId = Get-SubscriptionIdEncoded -SubscriptionId $SubscriptionId5253# Build the encoded resource path54# Format: {encoded-sub-id},{resource-group},,{foundry-resource},{project-name}55# Note: Two commas between resource-group and foundry-resource56$encodedPath = "$encodedSubId,$ResourceGroup,,$FoundryResource,$ProjectName"5758# Build the full URL59$baseUrl = "https://ai.azure.com/nextgen/r/"60$deploymentPath = "/build/models/deployments/$DeploymentName/details"6162return "$baseUrl$encodedPath$deploymentPath"63}6465# Generate and output the URL66$url = Get-FoundryDeploymentUrl `67-SubscriptionId $SubscriptionId `68-ResourceGroup $ResourceGroup `69-FoundryResource $FoundryResource `70-ProjectName $ProjectName `71-DeploymentName $DeploymentName7273Write-Output $url74