Skip to content

Commit cea7450

Browse files
Merge pull request #5066 from Blackmist/427254-sfi
fixes
2 parents 9cf79d5 + 690a936 commit cea7450

File tree

1 file changed

+19
-32
lines changed

1 file changed

+19
-32
lines changed

articles/ai-foundry/how-to/develop/connections-add-sdk.md

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ There are various authentication methods for the different connection types. Whe
4242

4343
## Azure OpenAI in Foundry Models
4444

45-
The following example creates an Azure OpenAI in Azure AI Foundry Models connection.
45+
The following example uses the [AzureOpenAIConnection](/python/api/azure-ai-ml/azure.ai.ml.entities.azureopenaiconnection) class to create an Azure OpenAI in Azure AI Foundry Models connection.
4646

4747
> [!TIP]
4848
> To connect to Azure OpenAI and more AI services with one connection, you can use the [AI services connection](#azure-ai-services) instead.
4949
5050
```python
51-
from azure.ai.ml.entities import AzureOpenAIConnection, ApiKeyConfiguration
52-
from azure.ai.ml.entities import UsernamePasswordConfiguration
53-
51+
from azure.ai.ml.entities import AzureOpenAIConnection
5452
name = "XXXXXXXXX"
5553

5654
target = "https://XXXXXXXXX.cognitiveservices.azure.com/"
@@ -59,9 +57,6 @@ resource_id= "Azure-resource-id"
5957

6058
# Microsoft Entra ID
6159
credentials = None
62-
# Uncomment the following if you need to use API key instead
63-
# api_key= "my-key"
64-
# credentials = ApiKeyConfiguration(key=api_key)
6560

6661
wps_connection = AzureOpenAIConnection(
6762
name=name,
@@ -75,22 +70,19 @@ ml_client.connections.create_or_update(wps_connection)
7570

7671
## Azure AI services
7772

78-
The following example creates an Azure AI services connection. This example creates one connection for the AI services documented in the [Connect to Azure AI services](../../../ai-services/connect-services-ai-foundry-portal.md) article. The same connection also supports Azure OpenAI.
73+
The following example uses the [AzureAIServicesConnection](/python/api/azure-ai-ml/azure.ai.ml.entities.azureaiservicesconnection) class to create an Azure AI services connection. This example creates one connection for the AI services documented in the [Connect to Azure AI services](../../../ai-services/connect-services-ai-foundry-portal.md) article. The same connection also supports Azure OpenAI.
7974

8075
```python
81-
from azure.ai.ml.entities import AzureAIServicesConnection, ApiKeyConfiguration
82-
from azure.ai.ml.entities import UsernamePasswordConfiguration
76+
from azure.ai.ml.entities import AzureAIServicesConnection
8377

8478
name = "my-ai-services"
8579

86-
target = "https://XXXXXXXXX.cognitiveservices.azure.com/"
80+
target = "https://my.cognitiveservices.azure.com/"
8781
resource_id=""
8882

8983
# Microsoft Entra ID
9084
credentials = None
91-
# Uncomment the following if you need to use API key instead
92-
# api_key= "my-key"
93-
# credentials = ApiKeyConfiguration(key=api_key)
85+
9486

9587
wps_connection = AzureAIServicesConnection(
9688
name=name,
@@ -103,20 +95,17 @@ ml_client.connections.create_or_update(wps_connection)
10395

10496
## Azure AI Search
10597

106-
The following example creates an Azure AI Search connection:
98+
The following example uses the [AzureAISearchConnection](/python/api/azure-ai-ml/azure.ai.ml.entities.azureaisearchconnection) class to create an Azure AI Search connection:
10799

108100
```python
109-
from azure.ai.ml.entities import AzureAISearchConnection, ApiKeyConfiguration
110-
from azure.ai.ml.entities import UsernamePasswordConfiguration
101+
from azure.ai.ml.entities import AzureAISearchConnection
111102

112103
name = "my_aisearch_demo_connection"
113-
target = "https://XXXXXXXXX.search.windows.net"
104+
target = "https://my.search.windows.net"
114105

115106
# Microsoft Entra ID
116107
credentials = None
117-
# Uncomment the following if you need to use API key instead
118-
# api_key= "my-key"
119-
# credentials = ApiKeyConfiguration(key=api_key)
108+
120109

121110
wps_connection = AzureAISearchConnection(
122111
name=name,
@@ -132,11 +121,10 @@ The following example creates an Azure AI Content Safety connection:
132121

133122
```python
134123
from azure.ai.ml.entities import AzureContentSafetyConnection, ApiKeyConfiguration
135-
from azure.ai.ml.entities import UsernamePasswordConfiguration
136124

137125
name = "my_content_safety"
138126

139-
target = "https://XXXXXXXXX.cognitiveservices.azure.com/"
127+
target = "https://my.cognitiveservices.azure.com/"
140128
api_key = "XXXXXXXXX"
141129

142130
wps_connection = AzureContentSafetyConnection(
@@ -157,7 +145,7 @@ from azure.ai.ml.entities import ServerlessConnection
157145

158146
name = "my_maas_apk"
159147

160-
endpoint = "https://XXXXXXXXX.eastus2.inference.ai.azure.com/"
148+
endpoint = "https://my.eastus2.inference.ai.azure.com/"
161149
api_key = "XXXXXXXXX"
162150
wps_connection = ServerlessConnection(
163151
name=name,
@@ -170,11 +158,10 @@ ml_client.connections.create_or_update(wps_connection)
170158

171159
## Azure Blob Storage
172160

173-
The following example creates an Azure Blob Storage connection. This connection is authenticated with an account key or a SAS token:
161+
The following example uses the [AzureBlobStoreConnection](/python/api/azure-ai-ml/azure.ai.ml.entities.azureblobstoreconnection) class to create an Azure Blob Storage connection. This connection is authenticated with an account key or a SAS token:
174162

175163
```python
176164
from azure.ai.ml.entities import AzureBlobStoreConnection, SasTokenConfiguration,AccountKeyConfiguration
177-
from azure.ai.ml.entities import UsernamePasswordConfiguration
178165

179166

180167
name = "my_blobstore"
@@ -198,7 +185,7 @@ The following example creates Azure Data Lake Storage Gen 2 connection. This con
198185

199186
```python
200187
from azure.ai.ml.entities import WorkspaceConnection
201-
from azure.ai.ml.entities import UsernamePasswordConfiguration, ServicePrincipalConfiguration
188+
from azure.ai.ml.entities import ServicePrincipalConfiguration
202189

203190
sp_config = ServicePrincipalConfiguration(
204191
tenant_id="XXXXXXXXXXXX",
@@ -222,7 +209,7 @@ ml_client.connections.create_or_update(workspace_connection=wps_connection)
222209

223210
## Microsoft OneLake
224211

225-
The following example creates a Microsoft OneLake connection. This connection is authenticated with a Service Principal:
212+
The following example uses the [MicrosoftOneLakeWorkspaceConnection](/python/api/azure-ai-ml/azure.ai.ml.entities.microsoftonelakeconnection) class to create a Microsoft OneLake connection. This connection is authenticated with a Service Principal:
226213

227214
```python
228215
from azure.ai.ml.entities import MicrosoftOneLakeWorkspaceConnection, OneLakeArtifact
@@ -254,7 +241,7 @@ ml_client.connections.create_or_update(workspace_connection=wps_connection)
254241

255242
## Serp
256243

257-
The following example creates a Serp connection:
244+
The following example uses the [SerpConnection](/python/api/azure-ai-ml/azure.ai.ml.entities.serpconnection) class:
258245

259246
```python
260247
from azure.ai.ml.entities import SerpConnection
@@ -271,7 +258,7 @@ ml_client.connections.create_or_update(wps_connection)
271258

272259
## OpenAI
273260

274-
The following example creates an OpenAI (not Azure OpenAI) connection:
261+
The following example uses the [OpenAIConnection](/python/api/azure-ai-ml/azure.ai.ml.entities.openaiconnection) class to create an OpenAI (not Azure OpenAI) connection:
275262

276263
```python
277264
from azure.ai.ml.entities import OpenAIConnection
@@ -288,11 +275,11 @@ ml_client.connections.create_or_update(wps_connection)
288275

289276
## Custom
290277

291-
The following example creates custom connection:
278+
The following example uses the [ApiKeyConfiguration](/python/api/azure-ai-ml/azure.ai.ml.entities.apikeyconnection) class to create custom connection:
292279

293280
```python
294281
from azure.ai.ml.entities import WorkspaceConnection
295-
from azure.ai.ml.entities import UsernamePasswordConfiguration, ApiKeyConfiguration
282+
from azure.ai.ml.entities import ApiKeyConfiguration
296283

297284

298285
name = "my_custom"

0 commit comments

Comments
 (0)