Hope you are doing good!
Azure Container Apps (formerly known as Azure Web App for Containers) primarily maps web applications to their root domains, and it doesn't offer built-in support for path-based routing within the app service itself. To achieve path-based routing like you described (e.g., having your client at app.example.com
and your API at app.example.com/api
), you typically need to use a reverse proxy or an API Gateway service.
Here's a general approach you can take:
- Azure Functions Proxy:
- You can use Azure Functions Proxies (previously known as Azure Functions Proxy) to achieve path-based routing.
- Create an Azure Function App.
- Add proxy rules to the
proxies.json
file in your Azure Function App, which will route requests to your client and API based on the URL path.- In your
proxies.json
file, you can define rules like:
- In your
- Add proxy rules to the
- Create an Azure Function App.
- You can use Azure Functions Proxies (previously known as Azure Functions Proxy) to achieve path-based routing.
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"/api": {
"matchCondition": {
"route": "/api/{*path}"
},
"backendUri": "https://your-api.azurewebsites.net/{path}"
},
"/": {
"matchCondition": {
"route": "/"
},
"backendUri": "https://your-client.azurewebsites.net"
}
}
}
```
- This configuration will route requests to **`/api`** to your API container app and requests to the root path **`/`** to your client container app.
1. **API Gateway Service (Optional)**:
- If you need more advanced features like rate limiting, caching, authentication, or API management, you can consider using Azure API Management. However, as you mentioned, it might be overkill for a small use case.
1. **Custom Domain Configuration**:
- Configure your custom domains (e.g., **`app.example.com`**) for both the Azure Function App (for path-based routing) and your client and API container apps.
1. **DNS Configuration**:
- Ensure your DNS records point to the appropriate Azure resources.
[https://docs.microsoft.com/azure](https://learn.microsoft.com/en-us/azure/container-apps/overview)
Please accept , if it helps., Thanks