Last active
August 24, 2024 20:37
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $SubscriptionId = '' | |
| $ModelName = 'gpt-35-turbo*' | |
| $ResourceGroups = Get-AzResourceGroup | |
| foreach ($ResourceGroup in $ResourceGroups) { | |
| Write-Output "Processing Resource Group $($ResourceGroup.ResourceGroupName)" | |
| $Accounts = Get-AzCognitiveServicesAccount -ResourceGroupName $ResourceGroup.ResourceGroupName | Where-Object { $_.Properties.Endpoint -like '*openai.azure.com*' } | Select-Object -ExpandProperty CustomSubDomainName | |
| foreach ($Account in $Accounts) { | |
| Write-Output "Processing OpenAI Account $($Account)" | |
| $Deployments = Get-AzCognitiveServicesAccountDeployment -AccountName $Account -ResourceGroupName $ResourceGroup.ResourceGroupName | |
| $Deployments = $Deployments | Where-Object { $_.Properties.Model.Name -like $ModelName } | |
| foreach ($Deployment in $Deployments) { | |
| Write-Output "Processing Deployment $($Deployment.Name)" | |
| $Url = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$($ResourceGroup.ResourceGroupName)/providers/Microsoft.CognitiveServices/accounts/$Account/deployments/$($Deployment.Name)?api-version=2023-05-01" | |
| $Body = @{ | |
| sku = @{ | |
| name = 'Standard' | |
| capacity = 40 | |
| } | |
| properties = @{ | |
| model = @{ | |
| format = 'OpenAI' | |
| name = $Deployment.Properties.Model.Name | |
| version = "$($Deployment.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