Azure / azure-functions-on-container-apps

Docs , samples and issues for Azure Functions on Azure Container Apps
MIT License
71 stars 15 forks source link

Bug: Bicep/ARM: Cannot modify this site because another operation is in progress. #34

Closed tang2087 closed 3 months ago

tang2087 commented 1 year ago

When I try to add function app using the bicep template provided into an existing managed environment (Azure Container App), I got the following error:

Cannot modify this site because another operation is in progress. Details: Id: 21b225f8-715c-44db-8f6c-7e39656e4b88, OperationName: Delete, CreatedTime: 9/15/2023 2:06:55 PM, RequestId: 00000000-0000-0000-0000-000000000000, EntityType: 2 (Target: /subscriptions/XXXX/resourceGroups/RG_XXX_PRD/providers/Microsoft.Resources/deployments/xxx-container-apps)

The bicep is based on the exmaple provided in this repo:

resource kontextContainerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-02-preview' = {
  name: containerAppEnvName
  location: location
  properties: {
    daprAIInstrumentationKey: kontextContainerAppsInsight.properties.InstrumentationKey
    appLogsConfiguration: {
      destination: 'log-analytics'
      logAnalyticsConfiguration: {
        customerId: logAnalyticsCutomerId
        sharedKey: logAnalyticsSharedKey
      }
    }
  }
}

resource kontextFunctionApp 'Microsoft.Web/sites@2022-09-01' = {
  name: kontextFunctionsAppName
  location: location
  kind: 'functionapp'
  properties: {
    managedEnvironmentId: kontextContainerAppEnvironment.id
    siteConfig: {
      linuxFxVersion: 'Docker|ghcr.io/***/kontext-functions:latest'
      appSettings: [
        {
          name: 'FUNCTIONS_WORKER_RUNTIME'
          value: 'dotnet-isolated'
        }
        {
          name: 'FUNCTIONS_EXTENSION_VERSION'
          value: '~4'
        }
        {
            name: 'DOCKER_REGISTRY_SERVER_URL'
            value: 'ghcr.io'
        }

The same error occurs if I use Azure Portal to add the app.

{
    "status": "Failed",
    "error": {
        "code": "Conflict",
        "message": "Cannot modify this site because another operation is in progress. Details: Id: 21b225f8-715c-44db-8f6c-7e39656e4b88, OperationName: Delete, CreatedTime: 9/15/2023 2:06:55 PM, RequestId: 00000000-0000-0000-0000-000000000000, EntityType: 2",
        "details": [
            {
                "message": "Cannot modify this site because another operation is in progress. Details: Id: 21b225f8-715c-44db-8f6c-7e39656e4b88, OperationName: Delete, CreatedTime: 9/15/2023 2:06:55 PM, RequestId: 00000000-0000-0000-0000-000000000000, EntityType: 2"
            },
            {
                "code": "Conflict"
            },
            {}
        ]
    }
}

Any suggestions about how to handle this error? The managed environment is hosting another web container app without any errors.

tang2087 commented 1 year ago

I have temporarily hosted the function in a new container app environment and it is working:

image

However I still want to be able to do this to use one single env for both my web app containers and Azure function app container.

rphoon commented 1 year ago

Having the same issue trying to deploy a powershell func app. I'm using an existing Container App Environment and have specified existing managedEnvironments in the bicep. Any idea what is causing the issue? Is it a setting in the Container App Environment?

tang2087 commented 1 year ago

Having the same issue trying to deploy a powershell func app. I'm using an existing Container App Environment and have specified existing managedEnvironments in the bicep. Any idea what is causing the issue? Is it a setting in the Container App Environment?

I have added this issue to this bug one: https://github.com/Azure/azure-functions-dotnet-worker/issues/1920

v-shenoy commented 1 year ago

Taking a look into this. @FahaoTang @rphoon

tang2087 commented 1 year ago

Taking a look into this. @FahaoTang @rphoon

Thanks @v-shenoy . It will be appreciated if you can help to look into another related 'bug': The above worked bicep template will create another resource group with name: container-app-env-nameFunctionApps****

I would expect the function container app itself to be created within the same resource group of the Function app itself.

v-shenoy commented 1 year ago

This is by design. For a given container apps environment, we create a resource group to hold the backing container apps. If you use the same environment to create more function apps, the container apps will be created in the same resource group.

This is to separate the Azure resources managed by the user, and the ones managed by the Microsoft.Web resource provider.

tang2087 commented 1 year ago

This is by design. For a given container apps environment, we create a resource group to hold the backing container apps. If you use the same environment to create more function apps, the container apps will be created in the same resource group.

This is to separate the Azure resources managed by the user, and the ones managed by the Microsoft.Web resource provider.

This is a strange design to me but I can live with it.

Any update about the original issue I raised?

tang2087 commented 11 months ago

Hi @v-shenoy just to follow up this again - is the issue fixed now? i.e. we cannot add azure function app to existing managed environment.

v-shenoy commented 11 months ago

Hi, @FahaoTang. Sorry for the delay here. Can you clarify few things for me?

  1. When was the managed environment created (if possible)?
  2. Are you able to create FAs on other MEs?

I will get back on this from my end with more info as well.

tang2087 commented 11 months ago

Hi, @FahaoTang. Sorry for the delay here. Can you clarify few things for me?

  1. When was the managed environment created (if possible)?

  2. Are you able to create FAs on other MEs?

I will get back on this from my end with more info as well.

It was created a few months ago for my website container app. I can create FAs with new MEs just not the ones that already have other web apps.

v-shenoy commented 11 months ago

@FahaoTang This was a known bug in the back end which has been fixed, but the issue is persisting in some cases where function app creation was done before the fix. I will manually run a fix-up operation and see if it resolves it.

tang2087 commented 10 months ago

Hi @v-shenoy any updates? I am really keen to deploy my containerized function app to the same Azure Contains Apps environment as my website so that I can share the same file share, etc.

v-shenoy commented 9 months ago

@FahaoTang We have verified from our end that the operation has been cleaned up. Could you check again? If not, then something else is causing this and we need to take a look, in which case please share the function app name and error messages.

tang2087 commented 9 months ago

@FahaoTang We have verified from our end that the operation has been cleaned up. Could you check again? If not, then something else is causing this and we need to take a look, in which case please share the function app name and error messages.

I feel this feature is half-cooked and doesn't align with my expected experience of deploying containerized function app into Azure Container Apps. Hence, I've reverted back to use service plan server farms.

jkonecki commented 6 months ago

Hello @v-shenoy, I'm running into the same issue when creating an Azure Function on an AppService Plan (that has other web apps) using ARM (I'm using Pulumi).

I'm getting the below error:

autorest/azure: Service returned an error. Status= . Cannot modify this site because another operation is in progress. Details: Id: be69ecf9-667f-41c9-8fac-9af2380f2c0d, OperationName: Create, CreatedTime: 3/11/2024 8:44:01 AM, RequestId: 2553d0db-c058-4d24-9632-6cf4ce719199, EntityType: 3

However, I can provision the Azure Function manually through the Portal. My FA uses VNet integration. I wonder if this is causing Create action by ARM to run into this kind of deadlock.

Please let me know if you need more info.

uyen-luu commented 4 weeks ago

This was closed but what is the solution? I'm still facing it when using Azure Function App on Container Deploy via Azure DevOps release pipeline.

alexdecoder commented 3 weeks ago

I am getting this error deploying Azure Functions App to a Container Apps Environment:

Cannot modify this site because another operation is in progress. Details: Id: ae8c14cd-77da-49bb-b644-77a8851f0a44, OperationName: ContainerAppUpdateSiteConfig, CreatedTime: 9/13/2024 9:01:46 PM, RequestId: b975d295-9e8d-4339-96c6-284b06cb2691, EntityType: 3

It appears that the AzureFunctionAppContainer@1 task is triggering the operation for ContainerAppUpdateSiteConfig twice

image

jjdd12 commented 2 weeks ago

I am getting this error deploying Azure Functions App to a Container Apps Environment:

Cannot modify this site because another operation is in progress. Details: Id: ae8c14cd-77da-49bb-b644-77a8851f0a44, OperationName: ContainerAppUpdateSiteConfig, CreatedTime: 9/13/2024 9:01:46 PM, RequestId: b975d295-9e8d-4339-96c6-284b06cb2691, EntityType: 3

It appears that the AzureFunctionAppContainer@1 task is triggering the operation for ContainerAppUpdateSiteConfig twice

image

I am getting the same thing