Skip to content

Commit 89c1d81

Browse files
authored
Merge pull request #281166 from MicrosoftDocs/main
7/18 11:00 AM IST Publish
2 parents b3f8f26 + fc4ae2a commit 89c1d81

File tree

51 files changed

+1321
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1321
-263
lines changed

.openpublishing.publish.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,12 @@
12251225
"url": "https://github.com/MicrosoftDocs/SupportArticles-docs",
12261226
"branch": "main",
12271227
"branch_mapping": {}
1228+
},
1229+
{
1230+
"path_to_root": "msdocs-python-fastapi-webapp-quickstart",
1231+
"url": "https://github.com/Azure-Samples/msdocs-python-fastapi-webapp-quickstart",
1232+
"branch": "main",
1233+
"branch_mapping": {}
12281234
}
12291235
],
12301236
"branch_target_mapping": {

articles/api-center/frequently-asked-questions.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ sections:
2121
2222
API Management is a runtime API governance and observability solution that enables you to expose APIs securely at scale, monitor their health, and analyze their usage. [Learn more](../api-management/api-management-key-concepts.md)
2323
24-
API Center is a design-time API governance and centralized API discovery solution. Use an API center to collect and maintain your organization's API inventory with rich metadata, and assess and help enforce API design consistency and quality.
24+
API Center is a design-time API governance and centralized API discovery solution. It acts as a repository and governance tool for all APIs within an organization, regardless of where they are in their lifecycle or where they are deployed. Use an API center to collect and maintain your organization's API inventory with rich metadata, and assess and help enforce API design consistency and quality.
2525

26-
Both services support portals for developers to discover APIs. In API Management, the developer portal is scoped to a single instance. In API Center, the portal can show APIs from any number of API Management instances, APIs managed with other API management solutions, and unmanaged APIs.
26+
Read more in [The Rising Significance of APIs - Azure API Management & API Center](https://techcommunity.microsoft.com/t5/azure-integration-services-blog/the-rising-significance-of-apis-azure-api-management-amp-api/ba-p/4181292).
2727

2828
- question: How do I use Azure API Center with my API management solution?
2929
answer: |
@@ -56,4 +56,4 @@ sections:
5656
additionalContent: |
5757
## Related content
5858
59-
To learn more, see [Azure API Center overview](overview.md).
59+
To learn more, see [Azure API Center overview](overview.md).

articles/app-service/includes/deploy-intelligent-apps/deploy-intelligent-apps-linux-java-pivot.md

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,51 +29,11 @@ For this Spring Boot application, we are building off the [quickstart](../../qui
2929
}
3030
```
3131

32-
### Secure your app with managed identity
33-
34-
Although optional, it's highly recommended to secure your application using [managed identity](../../overview-managed-identity.md) to authenticate your app to your Azure OpenAI resource. Skip this step if you are not using Azure OpenAI. This enables your application to access the Azure OpenAI resource without needing to manage API keys.
35-
36-
Follow the steps below to secure your application:
37-
38-
Add the Azure OpenAI dependency package. This package enables using Azure credentials in your app.
39-
40-
```java
41-
<dependency>
42-
<groupId>com.azure</groupId>
43-
<artifactId>azure-ai-openai</artifactId>
44-
<version>1.0.0-beta.9</version>
45-
</dependency>
46-
```
47-
48-
Next, include the default Azure default credentials when creating the client
49-
50-
```java
51-
TokenCredential defaultCredential = new DefaultAzureCredentialBuilder().build();
52-
53-
OpenAIClient client = new OpenAIClientBuilder()
54-
.credential(defaultCredential)
55-
.endpoint("{endpoint}")
56-
.buildClient();
57-
```
58-
59-
Once the credentials are added to the application, you’ll then need to enable managed identity in your application and grant access to the resource.
60-
61-
1. In your web app resource, navigate to the **Identity** blade and turn on **System assigned** and click **Save**
62-
2. Once System assigned identity is turned on, it will register the web app with Microsoft Entra ID and the web app can be granted permissions to access protected resources.
63-
3. Go to your Azure OpenAI resource and navigate to the **Access control (IAM)** blade on the left pane.
64-
4. Find the Grant access to this resource card and click on **Add role assignment**
65-
5. Search for the **Cognitive Services OpenAI User** role and click **Next**
66-
6. On the **Members** tab, find **Assign access to** and choose the **Managed identity** option
67-
7. Next, click on **+Select Members** and find your web app
68-
8. Click **Review + assign**
69-
70-
Your web app is now added as a cognitive service OpenAI user and can communicate to your Azure OpenAI resource.
71-
7232
### API Keys and Endpoints
7333

7434
First, you need to grab the keys and endpoint values from Azure OpenAI, or OpenAI and add them as secrets for use in your application. Retrieve and save the values for later use to build the client.
7535

76-
For Azure OpenAI, see [this documentation](../../../ai-services/openai/quickstart.md?pivots=programming-language-csharp&tabs=command-line%2Cpython#retrieve-key-and-endpoint) to retrieve the key and endpoint values. For our application, you need the following values:
36+
For Azure OpenAI, see [this documentation](../../../ai-services/openai/quickstart.md?pivots=programming-language-csharp&tabs=command-line%2Cpython#retrieve-key-and-endpoint) to retrieve the key and endpoint values. If you're planning to use [managed identity](../../overview-managed-identity.md) to secure your app you'll only need the `endpoint` value. Otherwise, you need each of the following:
7737

7838
- `endpoint`
7939
- `apiKey`
@@ -139,11 +99,11 @@ For OpenAI:
13999

140100
Before you can create the client, you first need to add the Azure SDK dependency. Add the following Azure OpenAI package to the *pom.xl* file and run the **mvn package** command to build the package.
141101

142-
```python
102+
```java
143103
<dependency>
144104
<groupId>com.azure</groupId>
145105
<artifactId>azure-ai-openai</artifactId>
146-
<version>1.0.0-beta.6</version>
106+
<version>1.0.0-beta.9</version>
147107
</dependency>
148108
```
149109

@@ -180,6 +140,36 @@ import com.azure.ai.openai.OpenAIClientBuilder;
180140
import com.azure.core.credential.AzureKeyCredential;
181141
```
182142

143+
### Secure your app with managed identity
144+
145+
Although optional, it's highly recommended to secure your application using [managed identity](../../overview-managed-identity.md) to authenticate your app to your Azure OpenAI resource. Skip this step if you are not using Azure OpenAI. This enables your application to access the Azure OpenAI resource without needing to manage API keys.
146+
147+
Follow the steps below to secure your application:
148+
149+
The Azure SDK package previously installed in the previous section enables the use of default credentials in your app. Include the default Azure default credentials when you create the client.
150+
151+
```java
152+
TokenCredential defaultCredential = new DefaultAzureCredentialBuilder().build();
153+
154+
OpenAIClient client = new OpenAIClientBuilder()
155+
.credential(defaultCredential)
156+
.endpoint(endpoint)
157+
.buildClient();
158+
```
159+
160+
Once the credentials are added to the application, you’ll then need to enable managed identity in your application and grant access to the resource.
161+
162+
1. In your web app resource, navigate to the **Identity** blade and turn on **System assigned** and click **Save**
163+
2. Once System assigned identity is turned on, it will register the web app with Microsoft Entra ID and the web app can be granted permissions to access protected resources.
164+
3. Go to your Azure OpenAI resource and navigate to the **Access control (IAM)** blade on the left pane.
165+
4. Find the Grant access to this resource card and click on **Add role assignment**
166+
5. Search for the **Cognitive Services OpenAI User** role and click **Next**
167+
6. On the **Members** tab, find **Assign access to** and choose the **Managed identity** option
168+
7. Next, click on **+Select Members** and find your web app
169+
8. Click **Review + assign**
170+
171+
Your web app is now added as a cognitive service OpenAI user and can communicate to your Azure OpenAI resource.
172+
183173
### Setup prompt and call to OpenAI
184174

185175
Now that our OpenAI service is created we can use the chat completions method to send our request message to OpenAI and return a response. Here's where we add our chat message prompt to the code to be passed to the chat completions method. Use the following code to set up the chat completions method:

articles/app-service/includes/deploy-intelligent-apps/deploy-intelligent-apps-linux-python-pivot.md

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ You can use Azure App Service to work with popular AI frameworks like LangChain
1919

2020
For this Flask web application, we are building off the [quickstart](../../quickstart-python.md?tabs=flask%2Cwindows%2Cazure-cli%2Cvscode-deploy%2Cdeploy-instructions-azportal%2Cterminal-bash%2Cdeploy-instructions-zip-azcli#1---sample-application) app and updating the *app.py* file to send and receive requests to an Azure OpenAI OR OpenAI service using LangChain.
2121

22-
First, copy and replace the *index.html* file with the following code:
22+
First, copy, and replace the *index.html* file with the following code:
2323

2424
```html
2525
<!doctype html>
@@ -54,7 +54,7 @@ First, copy and replace the *index.html* file with the following code:
5454
</html>
5555
```
5656

57-
Next, copy and replace the *hello.html* file with the following code:
57+
Next, copy, and replace the *hello.html* file with the following code:
5858

5959
```html
6060
<!doctype html>
@@ -82,54 +82,16 @@ Next, copy and replace the *hello.html* file with the following code:
8282

8383
After the files are updated, we can start preparing our environment variables to work with OpenAI.
8484

85-
### Secure your app with managed identity
86-
87-
Although optional, it's highly recommended to secure your application using [managed identity](../../overview-managed-identity.md) to authenticate your app to your Azure OpenAI resource. Skip this step if you are not using Azure OpenAI. This enables your application to access the Azure OpenAI resource without needing to manage API keys.
88-
89-
Follow the steps below to secure your application:
90-
91-
Add the identity package `Azure.Identity`. This package enables using Azure credentials in your app. Install the package and import the default credential and bearer token provider.
92-
93-
```python
94-
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
95-
```
96-
97-
Next, include the default Azure credentials and token provider in the AzureOpenAI options.
98-
99-
```python
100-
token_provider = get_bearer_token_provider(
101-
DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
102-
)
103-
104-
client = AzureOpenAI(
105-
api_version="2024-02-15-preview",
106-
azure_endpoint="https://{your-custom-endpoint}.openai.azure.com/",
107-
azure_ad_token_provider=token_provider
108-
)
109-
```
110-
111-
Once the credentials are added to the application, you’ll then need to enable managed identity in your application and grant access to the resource.
112-
113-
1. In your web app resource, navigate to the **Identity** blade and turn on **System assigned** and click **Save**
114-
2. Once System assigned identity is turned on, it will register the web app with Microsoft Entra ID and the web app can be granted permissions to access protected resources.
115-
3. Go to your Azure OpenAI resource and navigate to the **Access control (IAM)** blade on the left pane.
116-
4. Find the Grant access to this resource card and click on **Add role assignment**
117-
5. Search for the **Cognitive Services OpenAI User** role and click **Next**
118-
6. On the **Members** tab, find **Assign access to** and choose the **Managed identity** option
119-
7. Next, click on **+Select Members** and find your web app
120-
8. Click **Review + assign**
121-
122-
Your web app is now added as a cognitive service OpenAI user and can communicate to your Azure OpenAI resource.
123-
12485
### API Keys and Endpoints
12586

12687
In order to make calls to OpenAI with your client, you need to first grab the Keys and Endpoint values from Azure OpenAI, or OpenAI and add them as secrets for use in your application. Retrieve and save the values for later use.
12788

128-
For Azure OpenAI, see [this documentation](../../../ai-services/openai/quickstart.md?pivots=programming-language-csharp&tabs=command-line%2Cpython#retrieve-key-and-endpoint) to retrieve the key and endpoint values. For our application, you need the following values:
89+
For Azure OpenAI, see [this documentation](../../../ai-services/openai/quickstart.md?pivots=programming-language-csharp&tabs=command-line%2Cpython#retrieve-key-and-endpoint) to retrieve the key and endpoint values. If you're planning to use [managed identity](../../overview-managed-identity.md) to secure your app you'll only need the `api_version` and `azure__endpoint` values. Otherwise, you need each of the following:
12990

13091
- `api_key`
13192
- `api_version`
13293
- `azure_deployment`
94+
- `azure_endpoint`
13395
- `model_name`
13496

13597
For OpenAI, see this [documentation](https://platform.openai.com/docs/api-reference) to retrieve the API keys. For our application, you need the following values:
@@ -202,7 +164,7 @@ from langchain_openai import AzureOpenAI~~
202164

203165
After LangChain is imported into our file, you can add the code that will call to OpenAI with the LangChain invoke chat method. Update *app.py `http://app.py`* to include the following code:
204166

205-
For Azure OpenAI, use the following code:
167+
For Azure OpenAI, use the following code. If you plan to use managed identity you can use the credentials outlined in the following section for the Azure OpenAI parameters.
206168

207169
```python
208170
@app.route('/hello', methods=['POST'])
@@ -294,6 +256,45 @@ if __name__ == '__main__':
294256

295257
Now save the application and follow the next steps to deploy it to App Service. If you would like to test it locally first at this step, you can swap out the key and endpoint values with the literal string values of your OpenAI service. For example: model_name = 'gpt-4-turbo';
296258

259+
### Secure your app with managed identity
260+
261+
Although optional, it's highly recommended to secure your application using [managed identity](../../overview-managed-identity.md) to authenticate your app to your Azure OpenAI resource. Skip this step if you are not using Azure OpenAI. This enables your application to access the Azure OpenAI resource without needing to manage API keys.
262+
263+
Follow the steps below to secure your application:
264+
265+
Add the identity package `Azure.Identity`. This package enables using Azure credentials in your app. Install the package and import the default credential and bearer token provider.
266+
267+
```python
268+
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
269+
```
270+
271+
Next, include the default Azure credentials and token provider in the AzureOpenAI options.
272+
273+
```python
274+
token_provider = get_bearer_token_provider(
275+
DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
276+
)
277+
278+
client = AzureOpenAI(
279+
api_version="2024-02-15-preview",
280+
azure_endpoint="https://{your-custom-endpoint}.openai.azure.com/",
281+
azure_ad_token_provider=token_provider
282+
)
283+
```
284+
285+
Once the credentials are added to the application, you’ll then need to enable managed identity in your application and grant access to the resource.
286+
287+
1. In your web app resource, navigate to the **Identity** blade and turn on **System assigned** and click **Save**
288+
2. Once System assigned identity is turned on, it registers the web app with Microsoft Entra ID and the web app can be granted permissions to access protected resources.
289+
3. Go to your Azure OpenAI resource and navigate to the **Access control (IAM)** blade on the left pane.
290+
4. Find the Grant access to this resource card and click on **Add role assignment**
291+
5. Search for the **Cognitive Services OpenAI User** role and click **Next**
292+
6. On the **Members** tab, find **Assign access to** and choose the **Managed identity** option
293+
7. Next, click on **+Select Members** and find your web app
294+
8. Click **Review + assign**
295+
296+
Your web app is now added as a cognitive service OpenAI user and can communicate to your Azure OpenAI resource.
297+
297298
### Deploy to App Service
298299

299300
Before deploying to App Service, you need to edit the *requirments.txt* file and add an environment variable to your web app so it recognizes the LangChain library and build properly.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
author: JimacoMS4
3+
ms.author: v-jibrannian
4+
ms.topic: include
5+
ms.date: 07/02/2024
6+
---
7+
First, configure the startup command in Azure App Service. Navigate to the page for the App Service instance in the Azure portal.<br>
8+
<br>
9+
1. Select **Configuration** under the **Settings** heading in the menu on the left side of the page.
10+
1. Make sure the **General settings** tab is selected.
11+
1. In the **Startup Command** field, enter *gunicorn -w 2 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000 main:app*.
12+
1. Select **Save** to save your changes.
13+
1. Wait for the notification that the settings are updated before proceeding.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
author: JimacoMS4
3+
ms.author: v-jibrannian
4+
ms.topic: include
5+
ms.date: 07/02/2024
6+
---
7+
Next, restart the web app.<br>
8+
<br>
9+
1. Select **Overview** in the menu on the left side of the page.
10+
1. On the top menu, select **Restart**.

articles/app-service/includes/quickstart-python/deploy-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ ms.author: charris
44
ms.topic: include
55
ms.date: 04/01/2022
66
---
7-
Since the `az webapp up` command created the necessary resources and deployed your application in a single step, you can move on to [4 - Browse to the app](#4---browse-to-the-app).
7+
Since the `az webapp up` command created the necessary resources and deployed your application in a single step, you can move on to the next step.
88

99
---

articles/app-service/includes/quickstart-python/deploy-visual-studio-code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ ms.author: charris
44
ms.topic: include
55
ms.date: 04/01/2022
66
---
7-
Since the previous step created the necessary resources and deployed your application in a single step, you can move on to [4 - Browse to the app](#4---browse-to-the-app).
7+
Since the previous step created the necessary resources and deployed your application in a single step, you can move on to the next step.
88

99
---
12 KB
Loading
63.4 KB
Loading

0 commit comments

Comments
 (0)