Skip to content

Commit 61da8db

Browse files
committed
update code snippets
1 parent e48936e commit 61da8db

File tree

2 files changed

+33
-29
lines changed

2 files changed

+33
-29
lines changed

articles/ai-foundry/includes/create-project-fdp.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@ Use the following tabs to select the method you plan to use to create a [!INCLUD
4646
- You must be **Owner** of the subscription to receive the appropriate access control needed to use the project.
4747
- [Set up your development environment](../how-to/develop/install-cli-sdk.md?tabs=python)
4848
- Authenticate with `az login` or `az login --use-device-code` in your environment before running code.
49+
- Complete these steps to start your Python script:
50+
1. Install packages: `pip install azure-identity azure-mgmt-cognitiveservices`. If in a notebook cell, use `%pip install azure-identity azure-mgmt-cognitiveservices`.
51+
1. Use `pip show azure-mgmt-cognitiveservices` to verify your version is 13.7 or greater.
52+
1. Start your script with the following code to create the `client` connection and variables used throughout this article. This example creates the project in West US:
53+
54+
```python
55+
from azure.identity import DefaultAzureCredential
56+
from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient
57+
58+
sub_id = 'your-sub'
59+
rgp = 'your-resource-group'
60+
resource_name = 'your-resource'
61+
project_name = 'your-project'
62+
location = 'westus'
63+
64+
client = CognitiveServicesManagementClient(
65+
credential=DefaultAzureCredential(),
66+
subscription_id=sub_id,
67+
api_version="2025-04-01-preview"
68+
)
4969

5070

5171
# [Azure CLI](#tab/azurecli)
@@ -97,27 +117,11 @@ To customize the settings for your project, follow these steps:
97117

98118
To create a [!INCLUDE [fdp](../includes/fdp-project-name.md)]:
99119

100-
1. Install packages: `pip install azure-identity azure-mgmt-cognitiveservices`. If in a notebook cell, use `%pip install azure-identity azure-mgmt-cognitiveservices`.
101-
1. Use `pip show azure-mgmt-cognitiveservices` to verify your version is 13.7 or greater.
102-
1. Use the following code to create a [!INCLUDE [fdp-project-name](../includes/fdp-project-name.md)]. This example creates the project in West US:
120+
121+
1. Add this code to create a [!INCLUDE [fdp-project-name](../includes/fdp-project-name.md)], using the variables and `client` connection from the [Prerequisites](#prerequisites).
103122

104123
```python
105-
from azure.identity import DefaultAzureCredential
106-
from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient
107-
import os
108-
import json
109-
110-
sub_id = 'your-sub'
111-
rgp = 'your-resource-group'
112-
resource_name = 'your-resource'
113-
project_name = 'your-project'
114-
location = 'westus'
115-
116-
client = CognitiveServicesManagementClient(
117-
credential=DefaultAzureCredential(),
118-
subscription_id=sub_id,
119-
api_version="2025-04-01-preview"
120-
)
124+
121125
# Create resource
122126
resource = client.accounts.begin_create(
123127
resource_group_name=rgp,

articles/ai-foundry/includes/create-second-fdp-project.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,20 @@ Your first project (default project) plays a special role and has access to more
5151

5252
# [Python SDK](#tab/python)
5353

54+
Add this code to your script to create a new project on your existing
55+
5456
```python
5557
new_project_name = 'your-new-project-name'
5658

5759
project = client.projects.begin_create(
58-
resource_group_name=resource_group_name,
59-
account_name=foundry_resource_name,
60-
project_name=new_project_name,
61-
project={
62-
"location": location,
63-
"identity": {
64-
"type": "SystemAssigned"
65-
},
66-
"properties": {}
67-
}
60+
resource_group_name=rgp,
61+
account_name=resource_name,
62+
project_name=new_project_name,
63+
project={
64+
"location": location,
65+
"identity": {"type": "SystemAssigned"},
66+
"properties": {}
67+
}
6868
)
6969
```
7070

0 commit comments

Comments
 (0)