Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
369 stars 166 forks source link

azd infra synth fails with a project may only contain a single Aspire service and no other services at this time #3812

Open jonoabroad opened 2 weeks ago

jonoabroad commented 2 weeks ago

Output from azd version azd version 1.8.1 (commit 88369c36ce2a0d60794389aad9b10de938f587e1)

Describe the bug I have a single AppHost with 3 deployable applications, azd init runs fine.

To Reproduce azd infra synth

 azd infra synth --debug
2024/04/30 06:02:38 main.go:59: azd version: 1.8.1 (commit 88369c36ce2a0d60794389aad9b10de938f587e1)
2024/04/30 06:02:38 main.go:229: using cached latest version: 1.8.1 (expires on: 2024-04-30T17:59:35Z)
2024/04/30 06:02:38 project.go:120: Reading project from file 'C:\dev\SOLUTION_NAME\azure.yaml'
2024/04/30 06:02:38 project.go:120: Reading project from file 'C:\dev\SOLUTION_NAME\azure.yaml'
2024/04/30 06:02:38 middleware.go:106: running middleware 'debug'
2024/04/30 06:02:38 middleware.go:106: running middleware 'experimentation'
2024/04/30 06:02:38 experimentation.go:42: assignment context: 0g5ad841:76970;
2024/04/30 06:02:38 middleware.go:106: running middleware 'telemetry'
2024/04/30 06:02:38 telemetry.go:38: TraceID: 241a5be43073d51b8a31d582e0e6b01c

WARNING: Feature 'infraSynth' is in alpha stage.
To learn more about alpha features and their support, visit https://aka.ms/azd-feature-stages.

  (x) Failed: Synthesizing infrastructure

ERROR: a project may only contain a single Aspire service and no other services at this time.

Expected behavior A clear and concise description of what you expected to happen.

Environment .NET SDK: Version: 8.0.300-preview.24203.14 Commit: b7e38f457d Workload version: 8.0.300-manifests.1f2e3bea MSBuild version: 17.10.0+4f6b1bb28

Windows 11 23H2

Additional context

the Orchestration projects are in the root of solution, other projects are in a src directory

davidfowl commented 2 weeks ago

I believe this is being worked on by @ellismg

rajeshkamal5050 commented 2 weeks ago

@jonoabroad could you share the azure.yaml? cc @weikanglim @vhvb1989

Suspecting you have Aspire + non-Aspire services/projects described in azure.yaml. This is not supported today.

Aspire + azd is supported From an aspire project and azd POV, you should be having only this in azure.yaml

name: aspire-starter
services:
  app:
    language: dotnet
    project: ./aspire-starter.AppHost/aspire-starter.AppHost.csproj
    host: containerapp

Aspire + non-Aspire + azd is not supported. The below azure.yaml wouldn't work. Instead, you could try moving non-Aspire to Aspire services/projects described in app-host project model itself.

# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json

name: aspire-starter
services:
  app:
    language: dotnet
    project: ./aspire-starter.AppHost/aspire-starter.AppHost.csproj
    host: containerapp
  web:
    project: <path to your web project>
    module: <name of azure prov template>
    language: js
    host: containerapp
  api:
    project: <path to your api project>
    module: <name of azure prov template>
    language: csharp
    host: containerapp
jonoabroad commented 2 weeks ago

Hey @rajeshkamal5050 my azure.yaml looks like the latter.

I can't remember what generated it, but it wasn't me. I assume it was the --init command.

Should I be using a different command to create the azure.yaml definition?

rajeshkamal5050 commented 2 weeks ago

my azure.yaml looks like the latter. I can't remember what generated it, but it wasn't me. I assume it was the --init command.

Not sure what got you into that state @weikanglim @vhvb1989 any idea?

I have a single AppHost with 3 deployable applications, azd init runs fine.

@jonoabroad

If a complete aspire solution, then having the azure.yaml ex: like below based on your env name and project path/details should work.

name: aspire-starter
services:
  app:
    language: dotnet
    project: ./aspire-starter.AppHost/aspire-starter.AppHost.csproj
    host: containerapp

Also, you could try following the steps documented here with aspire starter project - https://learn.microsoft.com/en-us/dotnet/aspire/deployment/azure/aca-deployment-azd-in-depth and build on it.

jonoabroad commented 2 weeks ago

Running through the deploy in depth link and I get the expected output.

Let me try nuking my azure, .azure and infra files and directories and see what happens.

My project started from the azure starter project circa preview 4 and then I pulled in my projects from a non aspire project.

I do have a functions project, which I have leavered into the solution. It was working, Aspire had a few issues with it, but otherwise not deeply painful.

my azure.yaml looks like the latter. I can't remember what generated it, but it wasn't me. I assume it was the --init command.

Not sure what got you into that state @weikanglim @vhvb1989 any idea?

I have a single AppHost with 3 deployable applications, azd init runs fine.

@jonoabroad

If a complete aspire solution, then having the azure.yaml ex: like below based on your env name and project path/details should work.

name: aspire-starter
services:
  app:
    language: dotnet
    project: ./aspire-starter.AppHost/aspire-starter.AppHost.csproj
    host: containerapp

Also, you could try following the steps documented here with aspire starter project - https://learn.microsoft.com/en-us/dotnet/aspire/deployment/azure/aca-deployment-azd-in-depth and build on it.

jonoabroad commented 2 weeks ago

Okay interestingly,

Running through with the starter it isn't in the same order as the link, and I don't get an option to expose containers to public traffic.

azd did upgrade itself to azd version 1.8.2 (commit 14600c7a54edac4f54397413f8638431f5c16327) at one point.

with my project, it didn't discover the aspire project, but now has the option to add undiscovered projects, so I manually added it and removed all other projects.

Still getting the same error when I attempt to run azd up

azd up
? Select an Azure Subscription to use:  2. SUB_NAME(SUB_GUID)
? Select an Azure location to use: 48. (US) West Central US (westcentralus)

ERROR: resolving bicep parameters file: substituting environment variables inside parameter file: missing closing brace

I'll attempt to update the starter project showing what I am seeing and share it.

jonoabroad commented 2 weeks ago

calling azd up on the Aspire Starter solution I get the following

 azd up
? Select an Azure Subscription to use:  2. SUBSCRIPTION_NAME (SUBSCRIPTION_GUID)
? Select an Azure location to use: 48. (US) West Central US (westcentralus)

Packaging services (azd package)

SUCCESS: Your application was packaged for Azure in less than a second.

Provisioning Azure resources (azd provision)
Provisioning Azure resources can take some time.

Subscription: SUBSCRIPTION_NAME (SUBSCRIPTION_GUIDb)
Location: West Central US

  You can view detailed progress in the Azure Portal:
  https://portal.azure.com/#view/HubsExtension/DeploymentDetailsBlade/~/overview/id/%2Fsubscriptions%2FSUBSCRIPTION_GUID%2Fproviders%2FMicrosoft.Resources%2Fdeployments%2Fdevelop-REDACT

  (✓) Done: Resource group: rg-develop
  (✓) Done: Container Registry: acruhypt7zq7gd2y
  (✓) Done: Log Analytics workspace: law-uhypt7zq7gd2y
  (x) Failed: Container Apps Environment: cae-uhypt7zq7gd2y

ERROR: deployment failed: failing invoking action 'provision', error deploying infrastructure: deploying to subscription:

Deployment Error Details:
NoRegisteredProviderFound: No registered resource provider found for location 'westcentralus' and API version '2024-02-02-preview' for type 'managedEnvironments'. The supported api-versions are '2024-02-02-preview, 2022-03-01, 2022-06-01-preview, 2022-10-01, 2022-11-01-preview, 2023-04-01-preview, 2023-05-01, 2023-05-02-preview, 2023-08-01-preview, 2023-11-02-preview, 2024-03-01'. The supported locations are 'northcentralusstage, westus2, southeastasia, swedencentral, canadacentral, westeurope, northeurope, eastus, eastus2, eastasia, australiaeast, germanywestcentral, japaneast, uksouth, westus, centralus, northcentralus, southcentralus, koreacentral, brazilsouth, westus3, francecentral, southafricanorth, norwayeast, switzerlandnorth, uaenorth, canadaeast, westcentralus, ukwest, centralindia, italynorth, polandcentral'.

TraceID: c16ccbbf3cf469633c82d83ed058cb5a

ERROR: error executing step command 'provision': deployment failed: failing invoking action 'provision', error deploying infrastructure: deploying to subscription:

Deployment Error Details:
NoRegisteredProviderFound: No registered resource provider found for location 'westcentralus' and API version '2024-02-02-preview' for type 'managedEnvironments'. The supported api-versions are '2024-02-02-preview, 2022-03-01, 2022-06-01-preview, 2022-10-01, 2022-11-01-preview, 2023-04-01-preview, 2023-05-01, 2023-05-02-preview, 2023-08-01-preview, 2023-11-02-preview, 2024-03-01'. The supported locations are 'northcentralusstage, westus2, southeastasia, swedencentral, canadacentral, westeurope, northeurope, eastus, eastus2, eastasia, australiaeast, germanywestcentral, japaneast, uksouth, westus, centralus, northcentralus, southcentralus, koreacentral, brazilsouth, westus3, francecentral, southafricanorth, norwayeast, switzerlandnorth, uaenorth, canadaeast, westcentralus, ukwest, centralindia, italynorth, polandcentral'.

TraceID: c16ccbbf3cf469633c82d83ed058cb5a