Skip to content

Instantly share code, notes, and snippets.

@RylandDeGregory
Created January 28, 2024 00:29
Show Gist options
  • Save RylandDeGregory/42e58b8592ed5e15e55119c5af702137 to your computer and use it in GitHub Desktop.
Save RylandDeGregory/42e58b8592ed5e15e55119c5af702137 to your computer and use it in GitHub Desktop.
Update the Tokens Per Minute (TPM) quota limit for all Azure OpenAI Services in a given Azure Subscription
$SubscriptionId = ''
$ModelName = 'gpt-35-turbo*'
$RGs = Get-AzResourceGroup
foreach ($RG in $RGs) {
Write-Output "Processing Resource Group $($RG.ResourceGroupName)"
$Accounts = Get-AzCognitiveServicesAccount -ResourceGroupName $RG.ResourceGroupName | Where-Object { $_.Properties.Endpoint -like '*openai.azure.com*' } | Select-Object -ExpandProperty CustomSubDomainName
foreach ($Acct in $Accounts) {
Write-Output "Processing OpenAI Account $($Acct)"
$Deployments = Get-AzCognitiveServicesAccountDeployment -AccountName $Acct -ResourceGroupName $RG.ResourceGroupName
$35Deployments = $Deployments | Where-Object { $_.Properties.Model.Name -like $ModelName }
foreach ($Dep in $35Deployments) {
Write-Output "Processing Deployment $($Dep.Name)"
$Url = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$($RG.ResourceGroupName)/providers/Microsoft.CognitiveServices/accounts/$Acct/deployments/$($Dep.Name)?api-version=2023-05-01"
$Body = @{
sku = @{
name = 'Standard'
capacity = 40
}
properties = @{
model = @{
format = 'OpenAI'
name = $Dep.Properties.Model.Name
version = "$($Dep.Properties.Model.Version)"
}
}
} | ConvertTo-Json -Depth 10
Invoke-AzRestMethod -Uri $Url -Payload $Body -Method Put | Select-Object -ExpandProperty Content | ConvertFrom-Json | Format-List
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment