|
| 1 | +--- |
| 2 | +title: Configure Ingress for your app in Azure Container Apps |
| 3 | +description: How to configure ingress for your container app |
| 4 | +services: container-apps |
| 5 | +author: craigshoemaker |
| 6 | +ms.service: container-apps |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 03/28/2023 |
| 9 | +ms.author: cshoe |
| 10 | +ms.custom: ignite-fall-2021, event-tier1-build-2022 |
| 11 | +zone_pivot_groups: arm-azure-cli-portal |
| 12 | +--- |
| 13 | + |
| 14 | +# Configure Ingress for your app in Azure Container Apps |
| 15 | + |
| 16 | +This article shows you how to enable [ingress](ingress-overview.md) features for your container app. Ingress is an application-wide setting. Changes to ingress settings apply to all revisions simultaneously, and don't generate new revisions. |
| 17 | + |
| 18 | +## Ingress settings |
| 19 | + |
| 20 | +You can set the following ingress template properties: |
| 21 | + |
| 22 | +| Property | Description | Values | Required | |
| 23 | +|---|---|---|---| |
| 24 | +| `allowInsecure` | Allows insecure traffic to your container app. When set to `true` HTTP requests to port 80 aren't automatically redirected to port 443 using HTTPS, allowing insecure connections.| `false` (default), `true` enables insecure connections| No | |
| 25 | +| `clientCertificateMode` | Client certificate mode for mTLS authentication. Ignore indicates server drops client certificate on forwarding. Accept indicates server forwards client certificate but doesn't require a client certificate. Require indicates server requires a client certificate. | `Required`, `Accept`, `Ignore` (default) | No | |
| 26 | +| `customDomains` | Custom domain bindings for Container Apps' hostnames. See [Custom domains and certificates](custom-domains-certificates.md) | An array of bindings | No | |
| 27 | +| `exposedPort` | (TCP ingress only) The port TCP listens on. If `external` is `true`, the value must be unique in the Container Apps environment. | A port number from `1` to `65535`. (can't be `80` or `443`) | No | |
| 28 | +| `external` | Allow ingress to your app from outside its Container Apps environment. |`true` or `false`(default) | Yes | |
| 29 | +| `ipSecurityRestrictions` | IP ingress restrictions. See [Set up IP ingress restrictions](ip-restrictions.md) | An array of rules | No | |
| 30 | +| `stickySessions.affinity` | Enables [session affinity](sticky-sessions.md). | `none` (default), `sticky` | No | |
| 31 | +| `targetPort` | The port your container listens to for incoming requests. | Set this value to the port number that your container uses. For HTTP ingress, your application ingress endpoint is always exposed on port `443`. | Yes | |
| 32 | +| `traffic` | [Traffic splitting](traffic-splitting.md) weights split between revisions. | An array of rules | No | |
| 33 | +| `transport` | The transport protocol type. | auto (default) detects HTTP/1 or HTTP/2, `http` for HTTP/1, `http2` for HTTP/2, `tcp` for TCP. | No | |
| 34 | + |
| 35 | + |
| 36 | +## Enable ingress |
| 37 | + |
| 38 | +You can configure ingress for your container app using the Azure CLI, an ARM template, or the Azure portal. |
| 39 | + |
| 40 | +::: zone pivot="azure-cli" |
| 41 | + |
| 42 | +# [Azure CLI](#tab/azure-cli) |
| 43 | + |
| 44 | +This `az containerapp ingress enable` command enables ingress for your container app. You must specify the target port, and you can optionally set the exposed port if your transport type is `tcp`. |
| 45 | + |
| 46 | +```azurecli |
| 47 | +az containerapp ingress enable \ |
| 48 | + --name <app-name> \ |
| 49 | + --resource-group <resource-group> \ |
| 50 | + --target-port <target-port> \ |
| 51 | + --exposed-port <tcp-exposed-port> \ |
| 52 | + --transport <transport> \ |
| 53 | + --type <external> |
| 54 | + --allow-insecure |
| 55 | +``` |
| 56 | + |
| 57 | +`az containerapp ingress enable` ingress arguments: |
| 58 | + |
| 59 | +| Option | Property | Description | Values | Required | |
| 60 | +| --- | --- | --- | --- | --- | |
| 61 | +| `--type` | external | Allow ingress to your app from anywhere, or limit ingress to its internal |
| 62 | + Container Apps environment. | `external` or `internal` | Yes | |
| 63 | +|`--allow-insecure` | allowInsecure | Allow HTTP connections to your app. | | No | |
| 64 | +| `--target-port` | targetPort | The port your container listens to for incoming requests. | Set this value to the port number that your container uses. Your application ingress endpoint is always exposed on port `443`. | Yes | |
| 65 | +|`--exposed-port` | exposedPort | (TCP ingress only) An port for TCP ingress. If `external` is `true`, the value must be unique in the Container Apps environment if ingress is external. | A port number from `1` to `65535`. (can't be `80` or `443`) | No | |
| 66 | +|`--transport` | transport | The transport protocol type. | auto (default) detects HTTP/1 or HTTP/2, `http` for HTTP/1, `http2` for HTTP/2, `tcp` for TCP. | No | |
| 67 | + |
| 68 | +::: zone-end |
| 69 | + |
| 70 | +::: zone pivot="azure-portal" |
| 71 | + |
| 72 | +# [Portal](#tab/portal) |
| 73 | + |
| 74 | +Enable ingress for your container app by using the portal. |
| 75 | + |
| 76 | +You can enable ingress when you create your container app, or you can enable ingress for an existing container app. |
| 77 | +- To configure ingress when you create your container app, select **Ingress** from the **App Configuration** tab of the container app creation wizard. |
| 78 | +- To configure ingress for an existing container app, select **Ingress** from the **Settings** menu of the container app resource page. |
| 79 | + |
| 80 | +### Enabling ingress for your container app: |
| 81 | + |
| 82 | +You can configure ingress when you create your container app by using the Azure portal. |
| 83 | + |
| 84 | + |
| 85 | +1. Set **Ingress** to **Enabled**. |
| 86 | +1. Configure the ingress settings for your container app. |
| 87 | +1. Select **Limited to Container Apps Environment** for internal ingress or **Accepting traffic from anywhere** for external ingress. |
| 88 | +1. Select the **Ingress Type**: **HTTP** or **TCP** (TCP ingress is only available in environments configured with a custom VNET). |
| 89 | +1. If *HTTP* is selected for the **Ingress Type**, select the **Transport**: **Auto**, **HTTP/1** or **HTTP/2**. |
| 90 | +1. Select **Insecure connections** if you want to allow HTTP connections to your app. |
| 91 | +1. Enter the **Target port** for your container app. |
| 92 | +1. If you have selected **TCP** for the **Transport** option, enter the **Exposed port** for your container app. The exposed port number can be `1` to `65535`. (can't be `80` or `443`) |
| 93 | + |
| 94 | +The **Ingress** settings page for your container app also allows you to configure **IP Restrictions**. For information to configure IP restriction, see [IP Restrictions](ip-restrictions.md). |
| 95 | + |
| 96 | +::: zone-end |
| 97 | + |
| 98 | +::: zone pivot="azure-resource-manager" |
| 99 | + |
| 100 | +# [ARM template](#tab/arm-template) |
| 101 | + |
| 102 | +Enable ingress for your container app by using the `ingress` configuration property. Set the `external` property to `true`, and set your `transport` and `targetPort` properties. |
| 103 | +-`external` property can be set to *true* for external or *false* for internal ingress. |
| 104 | +- Set the `transport` to `auto` to detect HTTP/1 or HTTP/2, `http` for HTTP/1, `http2` for HTTP/2, or `tcp` for TCP. |
| 105 | +- Set the `targetPort` to the port number that your container uses. Your application ingress endpoint is always exposed on port `443`. |
| 106 | +- Set the `exposedPort` property if transport type is `tcp` to a port for TCP ingress. The value must be unique in the Container Apps environment if ingress is external. A port number from `1` to `65535`. (can't be `80` or `443`) |
| 107 | + |
| 108 | +```json |
| 109 | +{ |
| 110 | + ... |
| 111 | + "configuration": { |
| 112 | + "ingress": { |
| 113 | + "external": true, |
| 114 | + "transport": "tcp", |
| 115 | + "targetPort": 80, |
| 116 | + "exposedPort": 8080, |
| 117 | + }, |
| 118 | + } |
| 119 | +} |
| 120 | +``` |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | +::: zone-end |
| 125 | + |
| 126 | +::: zone pivot="azure-cli" |
| 127 | + |
| 128 | +## Disable ingress |
| 129 | + |
| 130 | +# [Azure CLI](#tab/azure-cli) |
| 131 | + |
| 132 | +Disable ingress for your container app by using the `az containerapp ingress` command. |
| 133 | + |
| 134 | +```azurecli |
| 135 | +az containerapp ingress disable \ |
| 136 | + --name <app-name> \ |
| 137 | + --resource-group <resource-group> \ |
| 138 | +``` |
| 139 | + |
| 140 | +::: zone-end |
| 141 | + |
| 142 | +::: zone pivot="azure-portal" |
| 143 | + |
| 144 | +# [Portal](#tab/portal) |
| 145 | + |
| 146 | +You can disable ingress for your container app using the portal. |
| 147 | + |
| 148 | +1. Select **Ingress** from the **Settings** menu of the container app page. |
| 149 | +1. Deselect the **Ingress** **Enabled** setting. |
| 150 | +1. Select **Save**. |
| 151 | + |
| 152 | +:::image type="content" source="media/ingress/screenshot-disable-ingress.png" alt-text="Sceenshot of disabling container app ingress."::: |
| 153 | + |
| 154 | +::: zone-end |
| 155 | + |
| 156 | +::: zone pivot="azure-resource-manager" |
| 157 | + |
| 158 | +# [ARM template](#tab/arm-template) |
| 159 | + |
| 160 | +Disable ingress for your container app by omitting the `ingress` configuration property from `properties.configuration` entirely. |
| 161 | + |
| 162 | +--- |
| 163 | + |
| 164 | +::: zone-end |
| 165 | + |
| 166 | +## Next steps |
| 167 | + |
| 168 | +> [!div class="nextstepaction"] |
| 169 | +> [Ingress in Azure Container Apps](ingress-overview.md) |
0 commit comments