1
1
---
2
- title : How to create a hub using the Azure Machine Learning SDK
2
+ title : How to create a hub using the Azure Machine Learning SDK/CLI
3
3
titleSuffix : Azure AI Studio
4
- description : This article provides instructions on how to create an AI Studio hub using the Azure Machine Learning SDK.
4
+ description : This article provides instructions on how to create an AI Studio hub using the Azure Machine Learning SDK and Azure CLI extension .
5
5
manager : nitinme
6
6
ms.service : azure-ai-studio
7
7
ms.custom :
@@ -13,11 +13,11 @@ ms.author: eur
13
13
author : eric-urban
14
14
---
15
15
16
- # Create a hub using the Azure Machine Learning SDK
16
+ # Create a hub using the Azure Machine Learning SDK and CLI
17
17
18
18
[ !INCLUDE [ Feature preview] ( ~/reusable-content/ce-skilling/azure/includes/ai-studio/includes/feature-preview.md )]
19
19
20
- In this article, you learn how to create the following AI Studio resources using the Azure Machine Learning SDK:
20
+ In this article, you learn how to create the following AI Studio resources using the Azure Machine Learning SDK and Azure CLI (with machine learning extension) :
21
21
- An Azure AI Studio hub
22
22
- An Azure AI Services connection
23
23
@@ -27,15 +27,26 @@ In this article, you learn how to create the following AI Studio resources using
27
27
28
28
## Set up your environment
29
29
30
+ Use the tabs below to select whether you are using the Python SDK or Azure CLI:
31
+
32
+ # [ Python SDK] ( #tab/python )
33
+
30
34
[ !INCLUDE [ SDK setup] ( ../../includes/development-environment-config.md )]
31
35
36
+ # [ Azure CLI] ( #tab/azurecli )
37
+
38
+ TODO
39
+
40
+ ---
41
+
32
42
## Create the AI Studio hub and AI Services connection
33
43
44
+ # [ Python SDK] ( #tab/python )
45
+
34
46
Use the following code to create a new hub and AI Services connection. Replace example string values with your own values:
35
47
36
48
``` Python
37
49
from azure.ai.ml.entities import Hub
38
- from azure.ai.ml.entities import AzureAIServicesConnection
39
50
40
51
my_hub_name = " myexamplehub"
41
52
my_location = " East US"
@@ -48,21 +59,66 @@ my_hub = Hub(name=my_hub_name,
48
59
49
60
created_hub = ml_client.workspaces.begin_create(my_hub).result()
50
61
62
+ ```
63
+
64
+ # [ Azure CLI] ( #tab/azurecli )
65
+
66
+ ``` azurecli
67
+ az ml workspace --kind hub --resource-group {my_resource_group} --name {my_hub_name}
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Create an AI Services connection
73
+
74
+ After creating your own AI Services, you can connect it to your hub:
75
+
76
+ # [ Python SDK] ( #tab/python )
77
+
78
+ ``` python
79
+ from azure.ai.ml.entities import AzureAIServicesConnection
80
+
51
81
# constrict an AI Services connection
52
82
my_connection_name = " myaiservivce"
53
83
my_endpoint = " demo.endpoint" # this could also be called target
54
84
my_api_keys = None # leave blank for Authentication type = AAD
55
85
my_ai_services_resource_id = " " # ARM id required
56
86
57
- my_connection = AIServicesConnection (name = my_connection_name,
87
+ my_connection = AzureAIServicesConnection (name = my_connection_name,
58
88
endpoint = my_endpoint,
59
89
api_key = my_api_keys,
60
90
ai_services_resource_id = my_ai_services_resource_id)
61
91
92
+ # Create the connection
62
93
ml_client.connections.create_or_update(my_connection)
63
94
```
64
95
96
+ # [ Azure CLI] ( #tab/azurecli )
97
+
98
+ ``` azurecli
99
+ az ml connection create --file {connection.yml} --resource-group {MY_RESOURCE_GROUP} --workspace-name {MY_PROJECT_NAME}
100
+ ```
101
+
102
+ You can use either an API key or credential-less YAML configuration file:
103
+
104
+ - API Key example:
105
+
106
+ ``` yml
107
+ name : myazai_ei
108
+ type : azure_ai_services
109
+ endpoint : https://contoso.cognitiveservices.azure.com/
110
+ api_key : XXXXXXXXXXXXXXX
111
+ ` ` `
65
112
113
+ - Credential-less
114
+
115
+ ` ` ` yml
116
+ name : myazai_apk
117
+ type : azure_ai_services
118
+ endpoint : https://contoso.cognitiveservices.azure.com/
119
+ ` ` `
120
+
121
+ ---
66
122
67
123
## Related content
68
124
0 commit comments