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

[Issue] azd provision and azd deploy Seem to Ignore AZD_INITIAL_ENVIRONMENT_CONFIG Content When Running in Azure DevOps Pipeline #4739

Open
essenbee2 opened this issue Jan 29, 2025 · 5 comments
Assignees
Milestone

Comments

@essenbee2
Copy link

essenbee2 commented Jan 29, 2025

azd version 1.11.1 (commit ae08ceb)

I have a .NET Aspire application that I can provision and deploy into Azure using azd provision and azd deploy when I run these commands locally on the command line. However, these commands fail when run as part of an Azure DevOps Pipeline.

I created the Azure Devops Pipeline in the following manner:

  • ran azd pipeline config --provider azdo
  • entered secrets and other params when prompted
  • updated the azure_dev.yml file to the following and committed:
# Run when commits are pushed to master
trigger: none

pool:
  vmImage: ubuntu-latest

steps:
  # setup-azd@0 needs to be manually installed in your organization
  # if you can't install it, you can use the below bash script to install azd
  # and remove this step
  - task: setup-azd@0
    displayName: Install azd

  # azd delegate auth to az to use service connection with AzureCLI@2
  - pwsh: |
      azd config set auth.useAzCliAuth "true"
    displayName: Configure AZD to Use AZ CLI Authentication.

  # DEBUG: print AZD_INITIAL_ENVIRONMENT_CONFIG for debugging
  - task: PowerShell@2
    displayName: Show var for debugging
    inputs:
      targetType: "inline"
      script: |
        Write-Host ($env:var1).substring(0,1);
        Write-Host ($env:var1).substring(1);
    env:
      var1: $(AZD_INITIAL_ENVIRONMENT_CONFIG)

  # Install .NET 9.0 SDK
  - task: UseDotNet@2
    displayName: Install .NET 9.0 SDK
    inputs:
      packageType: 'sdk'
      version: '9.0.x'
      installationPath: $(Agent.ToolsDirectory)/dotnet

  # Restore dependencies
  - task: DotNetCoreCLI@2
    displayName: Restore dependencies
    inputs:
      command: "restore"
      projects: "./ServiceLayerCore.sln"
      feedsToUse: "config"
      nugetConfigPath: "./NuGet.Config"

  # Build the project
  - task: DotNetCoreCLI@2
    displayName: Build Service Layer Core
    inputs:
      command: "build"
      projects: "./ServiceLayerCore.sln"
      arguments: "--configuration Release"

  - task: AzureCLI@2
    displayName: Provision Infrastructure
    inputs:
      azureSubscription: azconnection
      scriptType: bash
      scriptLocation: inlineScript
      keepAzSessionActive: true
      inlineScript: |
        cd $(Build.SourcesDirectory)/ServiceLayer.AppHost;
        azd provision --no-prompt
    env:
      AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
      AZURE_ENV_NAME: $(AZURE_ENV_NAME)
      AZURE_LOCATION: $(AZURE_LOCATION)
      AZD_INITIAL_ENVIRONMENT_CONFIG: $(AZD_INITIAL_ENVIRONMENT_CONFIG)

  - task: AzureCLI@2
    displayName: Deploy Application
    inputs:
      azureSubscription: azconnection
      scriptType: bash
      scriptLocation: inlineScript
      keepAzSessionActive: true
      inlineScript: |
        cd $(Build.SourcesDirectory)/ServiceLayer.AppHost;
        azd deploy --no-prompt;
    env:
      AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
      AZURE_ENV_NAME: $(AZURE_ENV_NAME)
      AZURE_LOCATION: $(AZURE_LOCATION)
      AZD_INITIAL_ENVIRONMENT_CONFIG: $(AZD_INITIAL_ENVIRONMENT_CONFIG)

When I run the pipeline, the Provision step fails with the error:

ERROR: initializing provisioning manager: prompting for value: no default response for prompt 'Enter a value for the 'AADB2CClientId' infrastructure parameter:'

However, the pipeline step DEBUG: print AZD_INITIAL_ENVIRONMENT_CONFIG for debugging printed out the value of the AZD_INITIAL_ENVIRONMENT_CONFIG and it definitely contains the infrastructure parameters e.g.

Image

No matter what I do, the pipeline always fails with the same error. It looks like azd is ignoring the values in the environment variable.

Any help on this would be gratefully received as this is currently blocking any progress I can make productionizing my application.

@rajeshkamal5050
Copy link
Contributor

@vhvb1989 can you take a look?

@vhvb1989
Copy link
Member

@essenbee2 , did you run azd pipeline config from within the root of your solution? or from within the AppHost folder? (is your azure.yaml file located on the root of your repo next to the .github folder?)

@essenbee2
Copy link
Author

essenbee2 commented Feb 1, 2025

Hi @vhvb1989

I ran azd init and azd pipeline config from within the ServiceLayer.AppHost folder. azure.yaml is in that folder. However, the .git file is in the root of the solution.

Image

@essenbee2
Copy link
Author

@vhvb1989 Thank you so much for the clue you provided! Running azd init and azd pipeline config from the root of the solution fixes the issue! I am so relieved to get this working.

@vhvb1989
Copy link
Member

vhvb1989 commented Feb 3, 2025

I am glad to hear that, @essenbee2 !

I am going to re-open this issue and follow up about the issue when running azd pipeline config from within the AppHost folder. That case should work just the same as running from the root of the repo.

Thank you for starting the conversation.

@vhvb1989 vhvb1989 reopened this Feb 3, 2025
@vhvb1989 vhvb1989 added the aspire label Feb 3, 2025
@rajeshkamal5050 rajeshkamal5050 added this to the Backlog milestone Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants