Azure / terraform-azure-container-apps

A Terraform module to deploy a container app in Azure
https://github.com/Azure/terraform-azure-container-apps
37 stars 24 forks source link

Azure API returned the following error: Status: "Failed" Code: "ContainerAppOperationError" Message: "Failed to provision revision for container app 'test-app'. Error details: Operation expired." Activity Id: "" #53

Open sahilvarmacsi opened 6 months ago

sahilvarmacsi commented 6 months ago

Is there an existing issue for this?

Greenfield/Brownfield provisioning

greenfield

Terraform Version

1.2.9

Module Version

~ 3.0

AzureRM Provider Version

~ 3.0

Affected Resource(s)/Data Source(s)

azurerm_container_app

Terraform Configuration Files

resource "azurerm_container_app" "container_app" {
  name                         = "test-app"
  container_app_environment_id = azurerm_container_app_environment.container_app_env.id
  resource_group_name          = var.container_app_rg
  revision_mode                = var.container_app_rev_mode
  workload_profile_name        = "Consumption"
  tags = var.tags_containerapp

  template {
    min_replicas = 1
    max_replicas = 10
    container {
      name   = "simplehelloworld"
      image  = "mcr.microsoft.com/k8se/quickstart:latest"
      cpu    = 1
      memory = "2Gi"
    }
  }

  identity {
    type         = "User Assigned"
    identity_ids = var.identity_ids
  }

  registry {
    server               = var.acr_server
    identity             = var.uami_resource_id
  }

  secret {
    name = var.secret_name
    value = var.secret_value
  }

  ingress {
    allow_insecure_connections = var.allow_insecure_connections
    external_enabled           = var.external_enabled
    target_port                = var.target_port
    transport                  = var.transport
    traffic_weight {
      latest_revision = var.latest_revision
      percentage      = var.percentage
    }
  }
  lifecycle {
    ignore_changes = [template, secret, ingress, registry]
  }
}

tfvars variables values

N/A

Debug Output/Panic Output

N/A

Expected Behaviour

Container App should get created.

Actual Behaviour

This error is happening only with a specific workspace. We got this created in a different workspace succesfully. Our container app is private and the container app environment is private has a workload profile. Same private container app and container app environment have been created using a different workspace. But it is weirdly throwing this issue only for a workspace that I am working to deploy for the Production Environment.

Error with details :

creating Container App (Subscription: "xxxxxxxxx" Resource Group Name: "rg-test" Container App Name: "test-app"): polling after CreateOrUpdate: polling failed: the Azure API returned the following error:

Status: "Failed" Code: "ContainerAppOperationError" Message: "Failed to provision revision for container app test-app'. Error details: Operation expired." Activity Id: ""


API Response:

----[start]---- {"id":"/subscriptions/xxxxxxxx/providers/Microsoft.App/locations/centralus/containerappOperationStatuses/xxxxxxxxxx","name":"xxxxxxxxxxx","status":"Failed","error":{"code":"ContainerAppOperationError","message":"Failed to provision revision for container app 'test-app'. Error details: Operation expired."},"startTime":"2024-03-12T15:51:13.3407187"} -----[end]-----

Steps to Reproduce

terraform apply on terraform cloud

Important Factoids

No response

References

No response

lonegunmanb commented 6 months ago

Thanks @sahilvarmacsi for opening this issue, it seems like you've declare an azurerm_container_app resource directly instead of using this module right? If the error was caused when you were using this module, could you please give us a minimum example code that could reproduce your issue? If the error was caused when you were using container app resource directly, then the AzureRM Provider repo is a better place for you to open the issue, you can open issue and ping me there. Thanks for your understanding.

sahilvarmacsi commented 6 months ago

I don't understand why it is failing. I just tried creating the Container App Manually through azure portal and it was stuck in provisioning state, this was a similar behavior when we were trying to create through terraform. So the reason why it was getting stuck in "Provisioning" state is because the secret was not getting created. I added the secret manually and the container app revision went to successful state.

image

Anyways I just imported the state of container app to my terraform. I don't understand the cause of failure only for this particular subscription. It get created fine in other subscription through terraform.