Skip to content

Commit 5c5e157

Browse files
committed
Merge branch 'main' into release-asr-h2a-deprecation
2 parents f6fcbb2 + 76697d6 commit 5c5e157

155 files changed

Lines changed: 2009 additions & 1407 deletions

File tree

Some content is hidden

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

.openpublishing.redirection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7188,6 +7188,11 @@
71887188
"source_path": "articles/reliability/reliability-operator-nexus.md",
71897189
"redirect_url": "/azure/reliability/overview-reliability-guidance",
71907190
"redirect_document_id": false
7191+
},
7192+
{
7193+
"source_path": "articles/reliability/reliability-event-hubs.md",
7194+
"redirect_url": "/azure/event-hubs/event-hubs-business-continuity-outages-disasters",
7195+
"redirect_document_id": false
71917196
}
71927197

71937198

articles/app-service/app-service-web-tutorial-rest-api.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how Azure App Service helps you host your RESTful APIs with C
44
ms.assetid: a820e400-06af-4852-8627-12b3db4a8e70
55
ms.devlang: csharp
66
ms.topic: tutorial
7-
ms.date: 09/05/2024
7+
ms.date: 08/29/2025
88
ms.update-cycle: 1095-days
99
ms.custom: "UpdateFrequency3, devx-track-csharp, mvc, devcenter, devx-track-azurecli"
1010
ms.author: msangapu
@@ -14,13 +14,13 @@ ms.service: azure-app-service
1414

1515
# Tutorial: Host a RESTful API with CORS in Azure App Service
1616

17-
[Azure App Service](overview.md) provides a highly scalable self-patching web hosting service. In addition, App Service has built-in support for [cross-origin resource sharing (CORS)](https://wikipedia.org/wiki/Cross-Origin_Resource_Sharing) for RESTful APIs. This tutorial shows how to deploy an ASP.NET Core API app to App Service with CORS support. You configure the app using command-line tools and deploy the app using Git.
17+
[Azure App Service](overview.md) provides a highly scalable self-patching web hosting service. In addition, App Service has built-in support for [cross-origin resource sharing (CORS)](https://wikipedia.org/wiki/Cross-Origin_Resource_Sharing) for RESTful APIs. This tutorial shows how to deploy an ASP.NET Core API app to App Service with CORS support. You configure the app by using command-line tools and deploy the app by using Git.
1818

1919
In this tutorial, you learn how to:
2020

2121
> [!div class="checklist"]
22-
> * Create App Service resources using Azure CLI.
23-
> * Deploy a RESTful API to Azure using Git.
22+
> * Create App Service resources by the using the Azure CLI.
23+
> * Deploy a RESTful API to Azure by using Git.
2424
> * Enable App Service CORS support.
2525
2626
You can complete this tutorial on macOS, Linux, or Windows.
@@ -47,7 +47,7 @@ In this step, you set up the local ASP.NET Core project. App Service supports th
4747
cd dotnet-core-api
4848
```
4949

50-
This repository contains an app that's created based on the tutorial [ASP.NET Core web API documentation with Swagger / OpenAPI](/aspnet/core/tutorials/web-api-help-pages-using-swagger?tabs=visual-studio). It uses a Swagger generator to serve the [Swagger UI](https://swagger.io/swagger-ui/) and the Swagger JSON endpoint.
50+
This repository contains an app that's based on the tutorial [ASP.NET Core web API documentation with Swagger / OpenAPI](/aspnet/core/tutorials/web-api-help-pages-using-swagger?tabs=visual-studio). It uses a Swagger generator to serve the [Swagger UI](https://swagger.io/swagger-ui/) and the Swagger JSON endpoint.
5151
5252
1. Make sure the default branch is `main`.
5353
@@ -56,7 +56,7 @@ In this step, you set up the local ASP.NET Core project. App Service supports th
5656
```
5757
5858
> [!TIP]
59-
> The branch name change isn't required by App Service. However, since many repositories are changing their default branch to `main` (see [Change deployment branch](deploy-local-git.md#change-deployment-branch)), this tutorial shows you how to deploy a repository from `main`.
59+
> The branch name change isn't required by App Service. However, because many repositories are changing their default branch to `main` (see [Change deployment branch](deploy-local-git.md#change-deployment-branch)), this tutorial shows how to deploy a repository from `main`.
6060

6161
### Run the application
6262

@@ -67,13 +67,13 @@ In this step, you set up the local ASP.NET Core project. App Service supports th
6767
dotnet run
6868
```
6969

70-
1. Navigate to `http://localhost:5000/swagger` in a browser to try the Swagger UI.
70+
1. Go to `http://localhost:5000/swagger` in a browser to try the Swagger UI.
7171

7272
![Screenshot of an ASP.NET Core API running locally.](./media/app-service-web-tutorial-rest-api/azure-app-service-local-swagger-ui.png)
7373

74-
1. Navigate to `http://localhost:5000/api/todo` to see a list of ToDo JSON items.
74+
1. Go to `http://localhost:5000/api/todo` to see a list of ToDo JSON items.
7575

76-
1. Navigate to `http://localhost:5000` and experiment with the browser app. Later, you'll point the browser app to a remote API in App Service to test CORS functionality. Code for the browser app is found in the repository's _wwwroot_ directory.
76+
1. Go to `http://localhost:5000` and experiment with the browser app. Later, you'll point the browser app to a remote API in App Service to test CORS functionality. Code for the browser app is found in the repository's _wwwroot_ directory.
7777

7878
1. To stop ASP.NET Core at any time, select **Ctrl+C** in the terminal.
7979

@@ -132,13 +132,13 @@ In this step, you deploy your .NET Core application to App Service.
132132

133133
### Browse to the Azure app
134134

135-
1. Navigate to `http://<app_name>.azurewebsites.net/swagger` in a browser and view the Swagger UI.
135+
1. Go to `http://<app_name>.azurewebsites.net/swagger` in a browser and view the Swagger UI.
136136

137137
![Screenshot of an ASP.NET Core API running in Azure App Service.](./media/app-service-web-tutorial-rest-api/azure-app-service-browse-app.png)
138138

139-
1. Navigate to `http://<app_name>.azurewebsites.net/swagger/v1/swagger.json` to see the _swagger.json_ for your deployed API.
139+
1. Go to `http://<app_name>.azurewebsites.net/swagger/v1/swagger.json` to see the _swagger.json_ for your deployed API.
140140

141-
1. Navigate to `http://<app_name>.azurewebsites.net/api/todo` to see your deployed API working.
141+
1. Go to `http://<app_name>.azurewebsites.net/api/todo` to see your deployed API working.
142142

143143
## Add CORS functionality
144144

@@ -148,15 +148,15 @@ Next, you enable the built-in CORS support in App Service for your API.
148148

149149
1. In your local repository, open _wwwroot/index.html_.
150150

151-
1. On line 51, set the `apiEndpoint` variable to the URL of your deployed API (`http://<app_name>.azurewebsites.net`). Replace _\<appname>_ with your app name in App Service.
151+
1. On line 51, set the `apiEndpoint` variable to the URL of your deployed API (`http://<app_name>.azurewebsites.net`). Replace _\<appname>_ with your app name.
152152

153153
1. In your local terminal window, run the sample app again.
154154

155155
```bash
156156
dotnet run
157157
```
158158

159-
1. Navigate to the browser app at `http://localhost:5000`. Open the developer tools window in your browser (**Ctrl**+**Shift**+**i** in Chrome for Windows) and inspect the **Console** tab. You should now see the error message, `No 'Access-Control-Allow-Origin' header is present on the requested resource`.
159+
1. Go to the browser app at `http://localhost:5000`. Open the developer tools window in your browser (**Ctrl**+**Shift**+**i** in Chrome for Windows) and inspect the **Console** tab. You should now see the error message `No 'Access-Control-Allow-Origin' header is present on the requested resource`.
160160

161161
![Screenshot of the CORS error in the browser client.](./media/app-service-web-tutorial-rest-api/azure-app-service-cors-error.png)
162162

@@ -190,9 +190,9 @@ Congratulations, you're running an API in Azure App Service with CORS support.
190190
191191
#### App Service CORS vs. your CORS
192192
193-
You can use your own CORS utilities instead of App Service CORS for more flexibility. For example, you might want to specify different allowed origins for different routes or methods. Since App Service CORS lets you specify only one set of accepted origins for all API routes and methods, you would want to use your own CORS code. See how CORS is enabled in ASP.NET Core at [Enable CORS](/aspnet/core/security/cors).
193+
To get more flexibility, you can use your own CORS utilities instead of App Service CORS. For example, you might want to specify different allowed origins for different routes or methods. Because App Service CORS lets you specify only one set of accepted origins for all API routes and methods, you would need to use your own CORS code. To learn how to enable CORS in ASP.NET Core, see [Enable CORS](/aspnet/core/security/cors).
194194
195-
The built-in App Service CORS feature doesn't have options to allow only specific HTTP methods or verbs for each origin that you specify. It will automatically allow all methods and headers for each origin defined. This behavior is similar to [ASP.NET Core CORS](/aspnet/core/security/cors) policies when you use the options `.AllowAnyHeader()` and `.AllowAnyMethod()` in the code.
195+
The built-in App Service CORS feature doesn't have options to allow only specific HTTP methods or verbs for each origin that you specify. It automatically allows all methods and headers for each origin defined. This behavior is similar to [ASP.NET Core CORS](/aspnet/core/security/cors) policies when you use the options `.AllowAnyHeader()` and `.AllowAnyMethod()` in the code.
196196

197197
> [!NOTE]
198198
> Don't try to use App Service CORS and your own CORS code together. If you try to use them together, App Service CORS takes precedence and your own CORS code has no effect.
@@ -201,7 +201,7 @@ The built-in App Service CORS feature doesn't have options to allow only specifi
201201
202202
#### How do I set allowed origins to a wildcard subdomain?
203203
204-
A wildcard subdomain like `*.contoso.com` is more restrictive than the wildcard origin `*`. The app's CORS management page in the Azure portal doesn't let you set a wildcard subdomain as an allowed origin. However, you can do that by using Azure CLI, like so:
204+
A wildcard subdomain like `*.contoso.com` is more restrictive than the wildcard origin `*`. The app's CORS management page in the Azure portal doesn't let you set a wildcard subdomain as an allowed origin. However, you can do that by using the Azure CLI:
205205
206206
```azurecli-interactive
207207
az webapp cors add --resource-group <group-name> --name <app-name> --allowed-origins 'https://*.contoso.com'
@@ -222,16 +222,16 @@ This operation isn't allowed when allowed origins include the wildcard origin `'
222222
[!INCLUDE [cli-samples-clean-up](../../includes/cli-samples-clean-up.md)]
223223
224224
<a name="next"></a>
225-
## Next steps
225+
## Next step
226226
227227
What you learned:
228228
229229
> [!div class="checklist"]
230-
> * Create App Service resources using Azure CLI.
231-
> * Deploy a RESTful API to Azure using Git.
230+
> * Create App Service resources by using the Azure CLI.
231+
> * Deploy a RESTful API to Azure by using Git.
232232
> * Enable App Service CORS support.
233233
234-
Go to the next tutorial to learn how to authenticate and authorize users.
234+
Go to the following tutorial to learn how to authenticate and authorize users.
235235
236236
> [!div class="nextstepaction"]
237237
> [Tutorial: Authenticate and authorize users end-to-end](tutorial-auth-aad.md)
11.4 KB
Loading
12.1 KB
Loading

0 commit comments

Comments
 (0)