Skip to content

Commit 7721644

Browse files
Merge pull request #2932 from sdgilley/sdg-freshness
freshness: update create-hub-project-sdk.md
2 parents 5b85742 + 3b0fc92 commit 7721644

File tree

1 file changed

+36
-19
lines changed

1 file changed

+36
-19
lines changed

articles/ai-studio/how-to/develop/create-hub-project-sdk.md

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ manager: scottpolly
66
ms.service: azure-ai-foundry
77
ms.custom: build-2024, devx-track-azurecli
88
ms.topic: how-to
9-
ms.date: 11/21/2024
9+
ms.date: 02/13/2025
1010
ms.reviewer: dantaylo
1111
ms.author: sgilley
1212
author: sdgilley
@@ -78,27 +78,40 @@ az ml workspace create --kind hub --resource-group {my_resource_group} --name {m
7878

7979
## Create an AI Services connection
8080

81-
After creating your own AI Services, you can connect it to your hub:
81+
After creating your own AI Services, you can connect it to your hub.
8282

8383
# [Python SDK](#tab/python)
8484

85-
```python
86-
from azure.ai.ml.entities import AzureAIServicesConnection
85+
1. Your `ml_client` connection now needs to include your hub:
8786

88-
# constrict an AI Services connection
89-
my_connection_name = "myaiservivce"
90-
my_endpoint = "demo.endpoint" # this could also be called target
91-
my_api_keys = None # leave blank for Authentication type = AAD
92-
my_ai_services_resource_id = "" # ARM id required
87+
* Provide your subscription details. For `<AML_WORKSPACE_NAME>`, use your hub name:
88+
89+
[!notebook-python[](~/azureml-examples-main/sdk/python/resources/connections/connections.ipynb?name=details)]
9390

94-
my_connection = AzureAIServicesConnection(name=my_connection_name,
95-
endpoint=my_endpoint,
96-
api_key= my_api_keys,
97-
ai_services_resource_id=my_ai_services_resource_id)
91+
* Get a handle to the hub:
9892

99-
# Create the connection
100-
ml_client.connections.create_or_update(my_connection)
101-
```
93+
[!notebook-python[](~/azureml-examples-main/sdk/python/resources/connections/connections.ipynb?name=ml_client)]
94+
95+
2. Use `ml_client` to create the connection to your AI Services:
96+
97+
```python
98+
from azure.ai.ml.entities import AzureAIServicesConnection
99+
100+
# construct an AI Services connection
101+
my_connection_name = "myaiservivce" # any name you want
102+
aiservices_resource_name = <resource_name> # copy from Azure AI Foundry portal
103+
my_endpoint = "<endpoint>" # copy from Azure AI Foundry portal
104+
my_api_keys = None # leave blank for Authentication type = AAD
105+
my_ai_services_resource_id = f"/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.CognitiveServices/accounts/{aiservices_resource_name}"
106+
107+
my_connection = AzureAIServicesConnection(name=my_connection_name,
108+
endpoint=my_endpoint,
109+
api_key= my_api_keys,
110+
ai_services_resource_id=my_ai_services_resource_id)
111+
112+
# Create the connection
113+
ml_client.connections.create_or_update(my_connection)
114+
```
102115

103116
# [Azure CLI](#tab/azurecli)
104117

@@ -113,26 +126,30 @@ You can use either an API key or credential-less YAML configuration file. For mo
113126
```yml
114127
name: myazai_ei
115128
type: azure_ai_services
116-
endpoint: https://contoso.cognitiveservices.azure.com/
129+
endpoint: <endpoint for your AI Services>
117130
api_key: XXXXXXXXXXXXXXX
131+
ai_services_resource_id: <fully_qualified_resource_id>
118132
```
119133
120134
- Credential-less
121135
122136
```yml
123137
name: myazai_apk
124138
type: azure_ai_services
125-
endpoint: https://contoso.cognitiveservices.azure.com/
139+
endpoint: <endpoint for your AI Services>
140+
ai_services_resource_id: <fully_qualified_resource_id>
126141
```
127142
143+
The <fully_qualified_resource_id> is the resource ID of your AI Services resource. It is in the format `/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.CognitiveServices/accounts/{aiservices_resource_name}`.
144+
128145
---
129146

130147
## Create an Azure AI Foundry hub using existing dependency resources
131148

132149
You can also create a hub using existing resources such as Azure Storage and Azure Key Vault. In the following examples, replace the example string values with your own values:
133150

134151
> [!TIP]
135-
> You can retrieve the resource ID of the storage account and key vault from the Azure Portal by going to the resource's overview and selecting __JSON view__. The resource ID is located in the __id__ field. You can also use the Azure CLI to retrieve the resource ID. For example, `az storage account show --name {my_storage_account_name} --query "id"` and `az keyvault show --name {my_key_vault_name} --query "id"`.
152+
> You can retrieve the resource ID of the storage account and key vault from the Azure portal by going to the resource's overview and selecting __JSON view__. The resource ID is located in the __id__ field. You can also use the Azure CLI to retrieve the resource ID. For example, `az storage account show --name {my_storage_account_name} --query "id"` and `az keyvault show --name {my_key_vault_name} --query "id"`.
136153

137154
# [Python SDK](#tab/python)
138155

0 commit comments

Comments
 (0)