azure-dev icon indicating copy to clipboard operation
azure-dev copied to clipboard

[Issue] Container Apps Naming locked when not created in Infra step

Open Gordonby opened this issue 2 years ago • 1 comments

  • [x] Make sure you've installed the latest version using instructions in the wiki

Output from azd version azd version 0.1.0-beta.4.1795201 (commit 9ebc364eef754c7717d234d8dca09ab17a0898a9)

Output from az version { "azure-cli": "2.39.0", "azure-cli-core": "2.39.0", "azure-cli-telemetry": "1.0.6", "extensions": { "aks-preview": "0.5.79", "azure-devops": "0.25.0", "azure-iot": "0.14.1", "containerapp": "0.3.6", "dev-spaces": "1.0.6", "k8s-configuration": "1.5.1", "k8s-extension": "1.2.2", "log-analytics": "0.2.2" } }

Context When deploying a Container App, i'm taking an approach that to only create the Container Apps into the environment after I've built the images for them.

Most of the current samples take the approach to create the Container App with a dummy image. Eg;

imageName: apiImageName != '' ? apiImageName : 'nginx:latest'

Describe the bug When your azd infra step does not want to create the App with a dummy image (instead letting it be created only after a container image is available) this leads to this type of error message;

Error: deploying service: deploying service checkout package: fetching service properties: failed running az resource show: exit code: 3, stdout: , stderr: ERROR: (ResourceNotFound) The Resource 'Microsoft.App/containerApps/gordapp6checkout' under resource group 'gordapp6-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix Code: ResourceNotFound Message: The Resource 'Microsoft.App/containerApps/gordapp6checkout' under resource group 'gordapp6-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix : exit status 3

When the Container App does not already exist in the environment, the name is not derived from the Container App tag. The container app must name named [ENVIRONMENT][SERVICE] in order for the deployment to succeed in this scenario. image

To Reproduce Run azd up from this commit:

Expected behavior To be able to have any container app name that i'd like, regardless of when the Container App was created.

ie: For azd to check the infra tags on Container Apps after the bicep deployment in the deploy step and update any local context it has from the tag.

Environment Information on your environment: * Language name and version * IDE and version : [e.g. Visual Studio 16.3]

Additional context See this PR for more context: https://github.com/Azure-Samples/pubsub-dapr-nodejs-servicebus/pull/3

Gordonby avatar Aug 24 '22 07:08 Gordonby

@jongio for visibility

Gordonby avatar Aug 24 '22 07:08 Gordonby

Same here - working on this PoC : https://github.com/KaiWalter/message-distribution

infra is deployed like

Created Resource group: kw-pubsub-rg
Created Key vault: keyvaultg6pq7pc4px2ge
Created Storage account: stg6pq7pc4px2ge
Created Log Analytics workspace: log-g6pq7pc4px2ge
Created Application Insights: appi-g6pq7pc4px2ge
Created Portal dashboard: appid-g6pq7pc4px2ge
Created Container Apps Environment: cae-g6pq7pc4px2ge
Created Container App: func-recvexp-g6pq7pc4px2ge
Created Container App: dapr-recvstd-g6pq7pc4px2ge
Created Container App: func-distributor-g6pq7pc4px2ge
Created Container App: func-recvstd-g6pq7pc4px2ge
Created Container App: dapr-recvexp-g6pq7pc4px2ge
Created Container App: dapr-distributor-g6pq7pc4px2ge
Created Container App: test-data-g6pq7pc4px2ge

but when Deploying service daprdist...

this error is displayed:

Error: deploying service: deploying service daprdist package: fetching service properties: failed retrieving container app properties: GET https://management.azure.com/subscriptions/853049fd-4889-45b6-aad9-f3f54421399c/resourceGroups/kw-pubsub-rg/providers/Microsoft.App/containerApps/kw-pubsubdaprdist
--------------------------------------------------------------------------------
RESPONSE 404: 404 Not Found
ERROR CODE: ResourceNotFound
--------------------------------------------------------------------------------
{
  "error": {
    "code": "ResourceNotFound",
    "message": "The Resource 'Microsoft.App/containerApps/kw-pubsubdaprdist' under resource group 'kw-pubsub-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"
  }
}

> azd version

azd version 0.3.0-beta.4 (commit 2f4c6d14f8a9afcdaaff769f3fa010040f1e9120)

> az version

{
  "azure-cli": "2.41.0",
  "azure-cli-core": "2.41.0",
  "azure-cli-telemetry": "1.0.8",
  "extensions": {
    "containerapp": "0.3.13"
  }
}

KaiWalter avatar Oct 26 '22 15:10 KaiWalter

I believe this is happening because azd deploy first tries to get the latest image. We could gracefully fail there if the service isn't found at that step.

jongio avatar Oct 31 '22 15:10 jongio

@Gordonby I have a PR out to address this. One thing that my team is a little worried about is how the azd concept of deploy is essentially to deploy application-code. For container apps, this line is blurred as deploying the application is also creating an Azure resource.

Curious if you can have any insights here:

  1. If creating the container app resource as part of the code deployment is the common scenario for container apps
  2. If you know of other Azure resource types for application hosting that follows a similar model

cc: @wbreza

weikanglim avatar Dec 07 '22 01:12 weikanglim

  1. Container Apps deployment best practices are still emerging. However what is not clean is needed to deploy a Container app with a dummy image and then replacing. This would make most architect's balk at the thought.

  2. It's certainly not a common model. Perhaps this should be feedback for container apps pg. Allow app creation without image.

Gordonby avatar Dec 07 '22 08:12 Gordonby