Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PublishAsAzureContainerApp with Resources results in broken bicep #8000

Open
1 task done
Fabian-Schmidt opened this issue Mar 11, 2025 · 7 comments
Open
1 task done
Labels
area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure external Issues that represent work that's external to this repo.

Comments

@Fabian-Schmidt
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When publishing an Azure Container App and configuring the resources results in not working bicep template.

The AppHost C# Code is:

    .PublishAsAzureContainerApp((module, app) =>
    {
        var container = app.Template.Containers.Single().Value!;
        container.Resources.Cpu = 0.25;
        container.Resources.Memory = "200Mi";
    });

Please note the Cpu field is of type BicepValue<double>.

The resulting bicep template:

resource frontend 'Microsoft.App/containerApps@2024-03-01' = {
  name: 'frontend'
  location: location
  properties: {
    configuration: {
      activeRevisionsMode: 'Single'
      ingress: { ... }
      registries: [ ... ]
    }
    environmentId: outputs_azure_container_apps_environment_id
    template: {
      containers: [
        {
          image: frontend_containerimage
          name: 'frontend'
          env: [...]
          resources: {
            cpu: '0,25'
            memory: '200Mi'
          }
        }

During azd up process the following is thrown:

{
  "error": {
    "code": "InvalidTemplateDeployment",
    "message": "The template deployment 'frontend-1741704029' is not valid according to the validation procedure. The tracking id is '40ca46c2-f9a0-4d8d-be3a-97023f6a8b6a'. See inner errors for details.",
    "details": [
      {
        "code": "ValidationForResourceFailed",
        "message": "Validation failed for a resource. Check 'Error.Details[0]' for more information.",
        "details": [
          {
            "code": "ContainerAppInvalidSchema",
            "message": "Invalid request body for container app. Path: $[0].resources.cpu. Does not conform to Container App schema, please visit for more information https://docs.microsoft.com/azure/container-apps/azure-resource-manager-api-spec?tabs=arm-template#container-app"
          }
        ]
      }
    ]
  }
}

Expected Behavior

The bicep template is working and the container is deployed with the configured cpu and memory settings.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version info

.NET SDK:
 Version:           9.0.200
 Commit:            90e8b202f2
 Workload version:  9.0.200-manifests.69179adf
 MSBuild version:   17.13.8+cbc39bea8

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.200\

Anything else?

  • Aspire.Hosting.AppHost - 9.1.0
  • Aspire.Hosting.Azure.AppContainers - 9.1.0
@github-actions github-actions bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 11, 2025
@eerhardt eerhardt added area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure and removed area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication labels Mar 11, 2025
@davidfowl
Copy link
Member

cc @tg-msft

@DanielToft
Copy link

I'm having the same problem. Bicep expects an integer but got a string.

Image

However, this works for some reason, but when some other error occurs, this validation error is displayed. This will mislead people in their debugging process.

@davidfowl
Copy link
Member

I'm having the same problem. Bicep expects an integer but got a string.

Those are known warnings we need to fix, but they don't cause deployment errors. This is different to what @Fabian-Schmidt is running into

@Fabian-Schmidt
Copy link
Author

I got the following workaround for the issue:

container.Resources.Cpu = Azure.Provisioning.Expressions.BicepFunction.ParseJson("0.25").Compile();
container.Resources.Memory = "0.5Gi";

This results in the following working bicep:

resources: {
  cpu: json('0.25')
  memory: '0.5Gi'
}

A bit bizarre to write it like this. Hopefully this can be fixed so I can remove this hack.

@davidfowl
Copy link
Member

davidfowl commented Mar 14, 2025

Yes this is clearly a bug in the Azure.Provisioning libraries.

@davidfowl davidfowl added the external Issues that represent work that's external to this repo. label Mar 14, 2025
@Juulsn
Copy link

Juulsn commented Mar 14, 2025

is this somehow related to #7685 ?

@davidfowl
Copy link
Member

I don't know how they are related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure external Issues that represent work that's external to this repo.
Projects
None yet
Development

No branches or pull requests

6 participants