Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

50%
+0 −0
Q&A "This model is not available on the selected Azure OpenAI Service resource." error, but I think it is. Why did I miss?

I've given up on that Azure UI, here's the Python code to do it. It requires a token generated via az account get-access-token. import json import requests new_capacity = 3 # Change this numbe...

posted 16h ago by Franck Dernoncourt‭

Answer
#1: Initial revision by user avatar Franck Dernoncourt‭ · 2025-04-19T00:34:47Z (about 16 hours ago)
I've given up on that Azure UI, here's the Python code to do it. It requires a token generated via [`az account get-access-token`](https://learn.microsoft.com/en-us/cli/azure/account?view=azure-cli-latest#az-account-get-access-token).

```python
import json
import requests

new_capacity = 3 # Change this number to your desired capacity. 3 means 3000 tokens/minute.

# Authentication and resource identification
token = "YOUR_BEARER_TOKEN"  # Replace with your actual token
subscription = ''
resource_group = ""
resource_name = ""
model_deployment_name = ""

# API parameters and headers
update_params = {'api-version': "2023-05-01"}
update_headers = {'Authorization': 'Bearer {}'.format(token), 'Content-Type': 'application/json'}

# First, get the current deployment to preserve its configuration
request_url = f'https://management.azure.com/subscriptions/{subscription}/resourceGroups/{resource_group}/providers/Microsoft.CognitiveServices/accounts/{resource_name}/deployments/{model_deployment_name}'
r = requests.get(request_url, params=update_params, headers=update_headers)

if r.status_code != 200:
    print(f"Failed to get current deployment: {r.status_code}")
    print(r.reason)
    if hasattr(r, 'json'):
        print(r.json())
    exit(1)

# Get the current deployment configuration
current_deployment = r.json()

# Update only the capacity in the configuration
update_data = {
    "sku": {
        "name": current_deployment["sku"]["name"],
        "capacity": new_capacity  
    },
    "properties": current_deployment["properties"]
}

update_data = json.dumps(update_data)

print('Updating deployment capacity...')

# Use PUT to update the deployment
r = requests.put(request_url, params=update_params, headers=update_headers, data=update_data)

print(f"Status code: {r.status_code}")
print(f"Reason: {r.reason}")
if hasattr(r, 'json'):
    print(r.json())
```

Takes a few seconds to get updated.