Hi ,
Thanks for reaching out to Microsoft Q&A.
The error indicates a mismatch between the resource type expected (Microsoft.App/containerApps
) and the one deployed (Microsoft.Web/sites
). This occurs because you are trying to use Azure Container Apps as the hosting environment, but your azurefunction.bicep
file is configured for a Function App running on App Service.
Here’s how you can resolve this issue:
- Review and Update
azurefunction.bicep
To use Azure Functions with Azure Container Apps, your resource definition should point to the Microsoft.App/containerApps
resource type, not Microsoft.Web/sites
.
Replace your existing functionapp
resource definition with one that uses Microsoft.App/containerApps
.
For example:
resource functionApp 'Microsoft.App/containerApps@2023-05-01' = {
name: 'func-${uniqueString(prefix, subscription().id)}'
location: location
properties: {
managedEnvironmentId: environmentId
configuration: {
secrets: [
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${listKeys(storageAccount.id, storageAccount.apiVersion).keys[0].value}'
}
]
activeRevisionsMode: 'Single'
ingress: {
external: true
targetPort: 80
transport: 'auto'
}
registries: [
{
server: acrUrl
username: ''
passwordSecretRef: 'acr-password'
}
]
dapr: {
enabled: false
}
}
template: {
containers: [
{
name: 'functionapp'
image: '${acrUrl}/azurefunctionsimage:v1.0.0'
resources: {
cpu: 0.25
memory: '0.5Gi'
}
env: [
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${listKeys(storageAccount.id, storageAccount.apiVersion).keys[0].value}'
}
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~4'
}
]
}
]
}
}
}
- Ensure
env.bicep
Is Correct
Ensure the managedEnvironments
resource in your env.bicep
is correctly configured and that environmentId
in azurefunction.bicep
references the correct managed environment.
- Update
azure.yaml
The host: containerapp
configuration is correct. Ensure the docker
section aligns with the updated resource definition and paths.
- Verify Dependencies
- Ensure that the
azd
CLI version is compatible with your configuration (>= 1.9.5
is required). - Ensure the container image (
azurefunctionsimage:v1.0.0
) exists in your Azure Container Registry and is correctly referenced.
- Deploy Again
Run the following command to redeploy your environment -->azd deploy
- Debugging Tips
- If the error persists, validate all resource configurations in the Azure Portal.
- Use
az resource list
to confirm that resources are created under the expected types (Microsoft.App/containerApps
).
These steps should align your deployment with the hosting requirements for Azure Container Apps.
Please feel free to click the 'Upvote' (Thumbs-up) button and 'Accept as Answer'. This helps the community by allowing others with similar queries to easily find the solution.