Skip to content

Commit 1c56f1b

Browse files
Merge pull request #2420 from mrbullwinkle/mrb_01_22_2025_cross_tenant
[Azure OpenAI] Cross Tenant
2 parents b1a5a62 + 7ebde99 commit 1c56f1b

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

articles/ai-services/openai/how-to/role-based-access-control.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ This role is typically granted access at the resource group level for a user in
9999
✅ Create new model deployments or edit existing model deployments (via API) <br>
100100
✅ Create custom fine-tuned models **[Added Fall 2023]**<br>
101101
✅ Upload datasets for fine-tuning **[Added Fall 2023]**<br>
102-
✅ Create new model deployments or edit existing model deployments (via Azure AI Foundry) **[Added Fall 2023]**
102+
✅ Create new model deployments or edit existing model deployments (via Azure AI Foundry) **[Added Fall 2023]**<br>
103103
✅ View, query, filter Stored completions data <br>
104104

105105

articles/ai-services/openai/includes/fine-tuning-python.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,55 @@ print(r.json())
503503

504504
To deploy between the same subscription, but different regions you would just have subscription and resource groups be identical for both source and destination variables and only the source and destination resource names would need to be unique.
505505

506+
### Cross tenant deployment
507+
508+
The accounts used to generate access tokens with `az account get-access-token --tenant` should have Cognitive Services OpenAI Contributor permissions to the associated Azure OpenAI resources.
509+
510+
```python
511+
import requests
512+
513+
subscription = "DESTINATION-SUBSCRIPTION-ID"
514+
resource_group = "DESTINATION-RESOURCE-GROUP"
515+
resource_name = "DESTINATION-AZURE-OPENAI-RESOURCE-NAME"
516+
model_deployment_name = "DESTINATION-MODEL-DEPLOYMENT-NAME"
517+
fine_tuned_model = "gpt-4o-mini-2024-07-18.ft-f8838e7c6d4a4cbe882a002815758510" #source fine-tuned model id example id provided
518+
source_subscription_id = "SOURCE-SUBSCRIPTION-ID"
519+
source_resource_group = "SOURCE-RESOURCE-GROUP"
520+
source_account = "SOURCE-AZURE-OPENAI-RESOURCE-NAME"
521+
522+
dest_token = "DESTINATION-ACCESS-TOKEN" # az account get-access-token --tenant DESTINATION-TENANT-ID
523+
source_token = "SOURCE-ACCESS-TOKEN" # az account get-access-token --tenant SOURCE-TENANT-ID
524+
525+
headers = {
526+
"Authorization": f"Bearer {dest_token}",
527+
"x-ms-authorization-auxiliary": f"Bearer {source_token}",
528+
"Content-Type": "application/json"
529+
}
530+
531+
url = f"https://management.azure.com/subscriptions/{subscription}/resourceGroups/{resource_group}/providers/Microsoft.CognitiveServices/accounts/{resource_name}/deployments/{model_deployment_name}?api-version=2024-10-01"
532+
533+
payload = {
534+
"sku": {
535+
"name": "standard",
536+
"capacity": 1
537+
},
538+
"properties": {
539+
"model": {
540+
"format": "OpenAI",
541+
"name": fine_tuned_model,
542+
"version": "1",
543+
"sourceAccount": f"/subscriptions/{source_subscription_id}/resourceGroups/{source_resource_group}/providers/Microsoft.CognitiveServices/accounts/{source_account}"
544+
}
545+
}
546+
}
547+
548+
response = requests.put(url, headers=headers, json=payload)
549+
550+
# Check response
551+
print(f"Status Code: {response.status_code}")
552+
print(f"Response: {response.json()}")
553+
```
554+
506555
### Deploy a model with Azure CLI
507556

508557
The following example shows how to use the Azure CLI to deploy your customized model. With the Azure CLI, you must specify a name for the deployment of your customized model. For more information about how to use the Azure CLI to deploy customized models, see [`az cognitiveservices account deployment`](/cli/azure/cognitiveservices/account/deployment).

articles/ai-services/openai/includes/fine-tuning-rest.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,29 @@ curl -X PUT "https://management.azure.com/subscriptions/<SUBSCRIPTION>/resourceG
322322

323323
To deploy between the same subscription, but different regions, you would just have subscription and resource groups be identical for both source and destination variables and only the source and destination resource names would need to be unique.
324324

325+
### Cross tenant deployment
326+
327+
The accounts used to generate access tokens with `az account get-access-token --tenant` should have Cognitive Services OpenAI Contributor permissions to the associated Azure OpenAI resources.
328+
329+
330+
```bash
331+
curl -X PUT "https://management.azure.com/subscriptions/<SUBSCRIPTION>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.CognitiveServices/accounts/<RESOURCE_NAME>/deployments/<MODEL_DEPLOYMENT_NAME>?api-version=2024-10-01" \
332+
-H "Authorization: Bearer <DESTINATION TOKEN>" \
333+
-H "x-ms-authorization-auxiliary: Bearer <SOURCE TOKEN>" \
334+
-H "Content-Type: application/json" \
335+
-d '{
336+
"sku": {"name": "standard", "capacity": 1},
337+
"properties": {
338+
"model": {
339+
"format": "OpenAI",
340+
"name": "<FINE_TUNED_MODEL>",
341+
"version": "1",
342+
"sourceAccount": "/subscriptions/{sourceSubscriptionID}/resourceGroups/{sourceResourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{sourceAccount}"
343+
}
344+
}
345+
}'
346+
```
347+
325348
### Deploy a model with Azure CLI
326349

327350
The following example shows how to use the Azure CLI to deploy your customized model. With the Azure CLI, you must specify a name for the deployment of your customized model. For more information about how to use the Azure CLI to deploy customized models, see [`az cognitiveservices account deployment`](/cli/azure/cognitiveservices/account/deployment).

0 commit comments

Comments
 (0)