Skip to content

Commit f577e77

Browse files
Merge pull request #5560 from MicrosoftDocs/main
Merged by Learn.Build PR Management system
2 parents ba67d73 + 6279350 commit f577e77

File tree

2 files changed

+19
-78
lines changed

2 files changed

+19
-78
lines changed

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

Lines changed: 17 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ ms.custom:
2929
* Fine-tuning
3030
* Playgrounds
3131

32-
3332
## Prerequisites
3433

3534
Use the following tabs to select the method you plan to use to create a [!INCLUDE [fdp](../includes/fdp-project-name.md)]:
@@ -49,23 +48,23 @@ Use the following tabs to select the method you plan to use to create a [!INCLUD
4948
- Complete these steps to start your Python script:
5049
1. Install packages: `pip install azure-identity azure-mgmt-cognitiveservices`. If in a notebook cell, use `%pip install azure-identity azure-mgmt-cognitiveservices`.
5150
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:
51+
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 East US:
5352

53+
:::code language="python" source="~/foundry-samples-main/samples/microsoft/python/mslearn-resources/quickstart/create_project.py" id="create_client":::
54+
55+
1. (Optional) If you have multiple accounts, add the tenant ID of the Microsoft Entra ID you wish to use into the `DefaultAzureCredential`. Find your tenant ID from the [Azure portal](https://portal.azure.com) under **Microsoft Entra ID, External Identities**.
56+
5457
```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-
)
58+
DefaultAzureCredential(interactive_browser_tenant_id="<TENANT_ID>")
59+
```
60+
61+
1. (Optional) If you're working on in the [Azure Government - US](/azure/azure-government/documentation-government-welcome) or [Azure China 21Vianet](https://azure.microsoft.com/global-infrastructure/services/?regions=china-east-2%2cchina-non-regional&products=all) regions, specify the region into which you want to authenticate. You can specify the region with `DefaultAzureCredential`. The following example authenticates to the Azure Government - US region:
62+
63+
```python
64+
from azure.identity import AzureAuthorityHosts
65+
DefaultAzureCredential(authority=AzureAuthorityHosts.AZURE_GOVERNMENT)
66+
```
67+
6968

7069

7170
# [Azure CLI](#tab/azurecli)
@@ -120,44 +119,7 @@ To create a [!INCLUDE [fdp](../includes/fdp-project-name.md)]:
120119

121120
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).
122121

123-
```python
124-
125-
# Create resource
126-
resource = client.accounts.begin_create(
127-
resource_group_name=rgp,
128-
account_name=resource_name,
129-
account={
130-
"location": location,
131-
"kind": "AIServices",
132-
"sku": {"name": "S0",},
133-
"identity": {"type": "SystemAssigned"},
134-
"properties": {"allowProjectManagement": True}
135-
}
136-
)
137-
# Create default project
138-
project = client.projects.begin_create(
139-
resource_group_name=rgp,
140-
account_name=resource_name,
141-
project_name=project_name,
142-
project={
143-
"location": location,
144-
"identity": {"type": "SystemAssigned"},
145-
"properties": {}
146-
}
147-
)
148-
```
149-
1. (Optional) If you have multiple accounts, add the tenant ID of the Microsoft Entra ID you wish to use into the `DefaultAzureCredential`. Find your tenant ID from the [Azure portal](https://portal.azure.com) under **Microsoft Entra ID, External Identities**.
150-
151-
```python
152-
DefaultAzureCredential(interactive_browser_tenant_id="<TENANT_ID>")
153-
```
154-
155-
1. (Optional) If you're working on in the [Azure Government - US](/azure/azure-government/documentation-government-welcome) or [Azure China 21Vianet](https://azure.microsoft.com/global-infrastructure/services/?regions=china-east-2%2cchina-non-regional&products=all) regions, specify the region into which you want to authenticate. You can specify the region with `DefaultAzureCredential`. The following example authenticates to the Azure Government - US region:
156-
157-
```python
158-
from azure.identity import AzureAuthorityHosts
159-
DefaultAzureCredential(authority=AzureAuthorityHosts.AZURE_GOVERNMENT)
160-
```
122+
:::code language="python" source="~/foundry-samples-main/samples/microsoft/python/mslearn-resources/quickstart/create_project.py" id="create_resource_project":::
161123

162124

163125
# [Azure CLI](#tab/azurecli)
@@ -204,15 +166,7 @@ On the project **Home** page, you can find information about the project.
204166

205167
# [Python SDK](#tab/python)
206168

207-
```python
208-
# Get project
209-
project = client.projects.get(
210-
resource_group_name=rgp,
211-
account_name=account_name,
212-
project_name=project_name
213-
)
214-
print(project)
215-
```
169+
:::code language="python" source="~/foundry-samples-main/samples/microsoft/python/mslearn-resources/quickstart/create_project.py" id="show_project":::
216170

217171
# [Azure CLI](#tab/azurecli)
218172

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,9 @@ 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
54+
Add this code to your script to create a new project on your existing resource:
5555

56-
```python
57-
new_project_name = 'your-new-project-name'
58-
59-
project = client.projects.begin_create(
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-
}
68-
)
69-
```
56+
:::code language="python" source="~/foundry-samples-main/samples/microsoft/python/mslearn-resources/quickstart/create_project.py" id="create_additional":::
7057

7158

7259
# [Azure CLI](#tab/azurecli)

0 commit comments

Comments
 (0)