Skip to content

Commit d48e277

Browse files
[Container Apps] New: .NET overview (#21)
1 parent fd76753 commit d48e277

File tree

1 file changed

+45
-47
lines changed

1 file changed

+45
-47
lines changed

articles/container-apps/dotnet-overview.md

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,69 +5,70 @@ services: container-apps
55
author: craigshoemaker
66
ms.service: container-apps
77
ms.topic: conceptual
8-
ms.date: 03/21/2024
8+
ms.date: 06/13/2024
99
ms.author: cshoe
1010
---
1111

1212
# .NET on Azure Container Apps overview
1313

14-
To deploy a .NET application to a cloud native environment like Azure Container Apps, there are a few things you need to consider to ensure your application runs smoothly and securely. This guide covers some key concepts and considerations for deploying a .NET application to Azure Container Apps.
14+
To deploy a .NET application to a cloud native environment like Azure Container Apps, there are decisions you need to make to ensure your application runs smoothly and securely. This guide covers key concepts involved in deploying a .NET application to Azure Container Apps.
1515

16-
## Overview
16+
Azure Container Apps is a fully managed serverless container service that allows you to run containerized applications without having to manage the underlying infrastructure. Container Apps includes built-in support for features including autoscaling, health checks, and transport layer security (TLS) certificates.
1717

18-
Azure Container Apps is a fully managed serverless container service that allows you to run containerized applications without having to manage the underlying infrastructure. It includes built-in support for features like auto-scaling, health checks, TLS certificates, and more. This makes Container Apps an ideal platform for running .NET applications in a cloud-native environment.
18+
This article details the concepts and concerns important to you as you deploy a .NET application on Azure Container Apps.
1919

20-
There are some important concepts and concerns you need to consider when deploying a .NET application to a cloud native environment like Azure Container Apps.
20+
## Select a resource type
2121

22-
## Select the right resource type
22+
Container Apps supports two types of resources: apps and jobs. Apps are continuously running services, while jobs are short-lived tasks designed to run to completion.
2323

24-
Container Apps supports two types of resources: apps and jobs. Apps are continuously-running services, while jobs are tasks that are designed to run to completion.
24+
As you prepare to deploy your app, consider differences between these two application types as their behavior affects how you manage your .NET application. The following table describes the difference in use cases between and jobs.
2525

26-
It's important to understand the difference between these two types of resources, as it'll affect how you deploy and manage your .NET application. The following are some examples of apps and jobs.
27-
28-
| Description | Resource type |
26+
| Use case | Resource type |
2927
|-------------|---------------|
3028
| An ASP.NET Core web API that serves HTTP requests | App |
3129
| A .NET Core console application that processes some data, then exits | Job |
3230
| A continuously running background service that processes messages from a queue | App |
31+
| An image optimization service that runs only when large images are saved to a storage account. | Job |
3332
| An application using a framework like Hangfire, Quartz.NET, or the Azure WebJobs SDK | App |
3433

3534
## Containerize and deploy your .NET application
3635

37-
For an app or job, you need to build a container image that contains your .NET application. To learn how to build a container image for a .NET application, see [Docker images for ASP.NET Core](/aspnet/core/host-and-deploy/docker/building-net-docker-images).
36+
For both apps or jobs, you need to build a container image to package your .NET application. For more information on building container image, see [Docker images for ASP.NET Core](/aspnet/core/host-and-deploy/docker/building-net-docker-images).
3837

39-
After you've added a Dockerfile to your .NET project, you can deploy it to Azure Container Apps by following these guides:
38+
Once set up, you can deploy your application to Azure Container Apps by following these guides:
4039

4140
* [Tutorial: Deploy to Azure Container Apps using Visual Studio](deploy-visual-studio.md)
4241
* [Quickstart: Build and deploy from a repository to Azure Container Apps](quickstart-repo-to-cloud.md)
4342
* [Create a job with Azure Container Apps](jobs-get-started-cli.md)
4443

4544
## Use the HTTP ingress
4645

47-
Azure Container Apps includes a built-in HTTP ingress that allows you to expose your apps to external traffic. To learn more, see [HTTP ingress in Azure Container Apps](ingress.md).
46+
Azure Container Apps includes a built-in HTTP ingress that allows you to expose your apps to traffic coming from outside the container. The Container Apps ingress sits between your app and the end user. Since the ingress acts as an intermediary, whatever the end user sees ends at the ingress, and whatever your app sees begins at the ingress.
4847

49-
All incoming requests are first handled by the ingress, then routed to your app. The ingress handles TLS termination and custom domains, so you don't need to configure them in your app.
48+
The ingress manages TLS termination and custom domains, eliminating the need for you to manually configure them in your app. Through the ingress, port `443` is exposed for HTTPS traffic, and optionally port `80` for HTTP traffic. The ingress forwards requests to your app at its target port.
5049

51-
The ingress exposes port 443 for HTTPS traffic. Optionally, it can also expose port 80 for HTTP traffic. The ingress forwards requests to your app at its target port.
50+
If your app needs metadata about the original request, it can use [X-forwarded headers](#define-x-forwarded-headers).
5251

53-
If your app needs metadata about the original request, it can use X-forwarded headers.
52+
To learn more, see [HTTP ingress in Azure Container Apps](ingress.md).
5453

55-
### Target port
54+
### Define a target port
5655

57-
To receive traffic, the ingress must be configured with the correct target port. The target port is the port that your app's HTTP server is listening to.
56+
To receive traffic, the ingress is configured on a target port where your app listens for traffic.
5857

59-
When ASP.NET Core is running in a container, the port(s) that it listens to is configured in the container image. When you use the [official ASP.NET Core images](/aspnet/core/host-and-deploy/docker/building-net-docker-images), your app is configured to listen to HTTP on a default port. The default port depends on the ASP.NET Core version:
58+
When ASP.NET Core is running in a container, the application listens to ports as configured in the container image. When you use the [official ASP.NET Core images](/aspnet/core/host-and-deploy/docker/building-net-docker-images), your app is configured to listen to HTTP on a default port. The default port depends on the ASP.NET Core version.
6059

61-
* ASP.NET Core 7 and earlier: `80`
62-
* ASP.NET Core 8 and later: `8080`
60+
| Runtime | Target port |
61+
|---|---|
62+
| ASP.NET Core 7 and earlier | `80` |
63+
| ASP.NET Core 8 and later | `8080` |
6364

6465
When you configure the ingress, set the target port to the number corresponding to the container image you're using.
6566

66-
### X-forwarded headers
67+
### Define X-forwarded headers
6768

68-
Because the original HTTP request is handled by the ingress, your app will see the ingress as the client. There are situations where your app needs to know the original client's IP address or the original protocol (HTTP or HTTPS). The HTTP ingress adds [`X-Forwarded-*` headers](ingress-overview.md#http-headers) to the request that contain this information.
69+
As the ingress handles the original HTTP request, your app sees the ingress as the client. There are some situations where your app needs to know the original client's IP address or the original protocol (HTTP or HTTPS). You can access the protocol and IP information via the request's [`X-Forwarded-*` header](ingress-overview.md#http-headers).
6970

70-
You can configure your ASP.NET Core app to use these headers by adding the following code:
71+
You can read original values from these headers by accessing the `ForwardedHeaders` object.
7172

7273
```csharp
7374
builder.Services.Configure<ForwardedHeadersOptions>(options =>
@@ -79,60 +80,57 @@ builder.Services.Configure<ForwardedHeadersOptions>(options =>
7980
});
8081
```
8182

82-
For more information, see [Configure ASP.NET Core to work with proxy servers and load balancers](/aspnet/core/host-and-deploy/proxy-load-balancer).
83+
For more information on working with request headers, see [Configure ASP.NET Core to work with proxy servers and load balancers](/aspnet/core/host-and-deploy/proxy-load-balancer).
8384

8485
## Build cloud-native .NET applications
8586

86-
Deploying to a cloud-native environment like Azure Container Apps requires you to build your .NET applications with cloud-native principles in mind.
87+
Applications deployed to Container Apps often work best when you build on the foundations of [cloud-native principles](/dotnet/architecture/cloud-native/definition). The following sections help detail common concerns surrounding cloud-native applications.
8788

8889
### Application configuration
8990

90-
When deploying your .NET application to Azure Container Apps, you should use environment variables for configuration instead of *appsettings.json*. This allows you to configure your application differently in different environments, and makes it easier to manage configuration values without having to rebuild and redeploy your container image.
91+
When deploying your .NET application to Azure Container Apps, use environment variables for storing configuration information instead of using *appsettings.json*. This practice allows you to configure your application in different ways in differing environments. Additionally, using environment variables makes it easier to manage configuration values without having to rebuild and redeploy your container image.
9192

92-
In Azure Container Apps, you set environment variables when you define your app or job's container. For settings that are sensitive, store them in secrets and reference them as environment variables. To learn more, see [Manage secrets in Azure Container Apps](manage-secrets.md).
93+
In Azure Container Apps, you [set environment variables](./environment-variables.md) when you define your app or job's container. Store sensitive values in secrets and reference them as environment variables. To learn more about managing secrets, see [Manage secrets in Azure Container Apps](manage-secrets.md).
9394

9495
### Managed identity
9596

96-
Azure Container Apps supports managed identity, which allows your app to access other Azure services without needing to manage credentials. To learn more, see [Managed identities in Azure Container Apps](managed-identity.md).
97+
Azure Container Apps supports managed identity, which allows your app to access other Azure services without needing to exchange credentials. To learn more about securely communicating between Azure services, see [Managed identities in Azure Container Apps](managed-identity.md).
9798

9899
### Logging
99100

100-
In a cloud-native environment, logging is crucial for monitoring and troubleshooting your applications. By default, Azure Container Apps uses Azure Log Analytics to collect logs from your containers. You also can configure other logging providers. To learn more, see [Log storage and monitoring options in Azure Container Apps](log-options.md).
101+
In a cloud-native environment, logging is crucial for monitoring and troubleshooting your applications. By default, Azure Container Apps uses Azure Log Analytics to collect logs from your containers. You can configure other logging providers. To learn more about application logging, see [Log storage and monitoring options in Azure Container Apps](log-options.md).
101102

102-
In your .NET application, configure a [logging provider](/aspnet/core/fundamentals/logging/) that writes logs to the console, and then Azure Container Apps will collect and store them.
103+
When you configure a [logging provider](/aspnet/core/fundamentals/logging/) that writes logs to the console, Azure Container Apps collects and stores log messages for you.
103104

104105
### Health probes
105106

106-
Azure Container Apps includes built-in support for health probes, which allow you to monitor the health of your applications and automatically restart them if they become unhealthy. To learn more, see [Health probes in Azure Container Apps](health-probes.md).
107+
Azure Container Apps includes built-in support for health probes, which allow you to monitor the health of your applications. If a probe determines your application is in an unhealthy state, then your container is automatically restarted. To learn more about health probes, see [Health probes in Azure Container Apps](health-probes.md).
107108

108-
In your ASP.NET Core application, you can configure a health check endpoint that Azure Container Apps can use to determine the health of your application. To learn more, see [Health checks in ASP.NET Core](/aspnet/core/host-and-deploy/health-checks).
109+
For a chance to implement custom logic to determine the health of your application, you can configure a health check endpoint. To learn more about health check endpoints, see [Health checks in ASP.NET Core](/aspnet/core/host-and-deploy/health-checks).
109110

110-
### Auto-scaling considerations
111+
### Autoscaling considerations
111112

112-
By default, Azure Container Apps automatically scales your ASP.NET Core apps based on the number of incoming HTTP requests. You can also configure custom auto-scaling rules based on other metrics, such as CPU or memory usage. To learn more, see [Set scaling rules in Azure Container Apps](scale-app.md).
113+
By default, Azure Container Apps automatically scales your ASP.NET Core apps based on the number of incoming HTTP requests. You can also configure custom autoscaling rules based on other metrics, such as CPU or memory usage. To learn more about scaling, see [Set scaling rules in Azure Container Apps](scale-app.md).
113114

114-
Auto-scaling changes the number of replicas of your app based on the rules you define. By default, Container Apps randomly routes incoming traffic to the replicas of your ASP.NET Core app. This means that your app should be stateless, so that clients don't experience any issues when their requests are routed to different replicas.
115+
Autoscaling changes the number of replicas of your app based on the rules you define. By default, Container Apps randomly routes incoming traffic to the replicas of your ASP.NET Core app. Since traffic can split among different replicas, your app should be stateless so your application doesn't experience state-related issues.
115116

116-
Features such as anti-forgery, authentication, and Razor Pages depend on data protection and will require additional configuration to work correctly when scaling to multiple replicas.
117+
Features such as anti-forgery, authentication, SignalR, Blazor Server, and Razor Pages depend on data protection require extra configuration to work correctly when scaling to multiple replicas.
117118

118119
#### Configure data protection
119120

120-
ASP.NET Core uses data protection to protect and unprotect data, such as session data and anti-forgery tokens. By default, data protection keys are stored in the file system, which isn't suitable for a cloud-native environment. When deploying your ASP.NET Core app to Azure Container Apps without `azd`, you must configure data protection to use shared locations like Azure Key Vault and Blob Storage for key persistence. When deploying with `azd`, the keys will be provided automatically to your app instances.
121+
ASP.NET Core has special features protect and unprotect data, such as session data and anti-forgery tokens. By default, data protection keys are stored on the file system, which isn't suitable for a cloud-native environment.
121122

122-
To configure data protection, refer to this documentation: [Configure ASP.NET Core Data Protection](https://github.com/aspnet/core/security/data-protection/configuration/overview).
123+
If you're deploying a .NET Aspire application, data protection is automatically configured for you. In all other situations, you need to [configure data protection manually](/aspnet/core/host-and-deploy/scaling-aspnet-apps/scaling-aspnet-apps?view=aspnetcore-8.0&tabs=login-azure-cli#connect-the-azure-services).
123124

124125
#### Configure ASP.NET Core SignalR
125126

126-
ASP.NET Core SignalR requires a backplane to distribute messages to multiple server replicas. When deploying your ASP.NET Core app with SignalR to Azure Container Apps, you must configure one of the supported backplanes, such as Azure SignalR Service or Redis. To learn more, see [ASP.NET Core SignalR hosting and scaling](/aspnet/core/signalr/scale).
127+
ASP.NET Core SignalR requires a backplane to distribute messages to multiple server replicas. When deploying your ASP.NET Core app with SignalR to Azure Container Apps, you must configure one of the supported backplanes, such as Azure SignalR Service or Redis. To learn more about backplanes, see [ASP.NET Core SignalR hosting and scaling](/aspnet/core/signalr/scale).
127128

128129
#### Configure Blazor Server
129130

130-
ASP.NET Core Blazor Server apps store state on the server, which means that each client must be connected to the same server replica for the duration of their session. When deploying your Blazor Server app to Azure Container Apps, you must enable sticky sessions to ensure that clients are routed to the same replica. To learn more, see [Session Affinity in Azure Container Apps](sticky-sessions.md).
131-
131+
ASP.NET Core Blazor Server apps store state on the server, which means that each client must be connected to the same server replica during their session. When deploying your Blazor Server app to Azure Container Apps, you must enable sticky sessions to ensure that clients are routed to the same replica. To learn more, see [Session Affinity in Azure Container Apps](sticky-sessions.md).
132132

133-
## Next steps
133+
## Related information
134134

135-
> [!div class="nextstepaction"]
136-
> [Deploy a .NET Aspire app](/dotnet/aspire/deployment/azure/aca-deployment)
137-
>
138-
> [Deploying and scaling an ASP.NET Core app on Azure Container Apps](/aspnet/core/host-and-deploy/scaling-aspnet-apps/scaling-aspnet-apps)
135+
* [Deploy a .NET Aspire app](/dotnet/aspire/deployment/azure/aca-deployment)
136+
* [Deploy and scale an ASP.NET Core app](/aspnet/core/host-and-deploy/scaling-aspnet-apps/scaling-aspnet-apps)

0 commit comments

Comments
 (0)