C
C#4w ago
essenbee

✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline

I am having a very frustrating problem deploying my .NET Aspire application system using azd deploy in Azure DevOps. I searched the issues and I tried these steps that I found, but to no avail: - create a pipeline variable called AZD_INITIAL_ENVIRONMENT_CONFIG - copy the contents of the .azure/<env_name>/config.json file into it - reference the variable in the YAML, like this:
- task: AzureCLI@2
displayName: Deploy Service Layer Core
inputs:
azureSubscription: azconnection
scriptType: bash
scriptLocation: inlineScript
keepAzSessionActive: true
inlineScript: |
cd $(Build.SourcesDirectory)/ServiceLayer.AppHost;
ls -la;
azd deploy --no-prompt --environment $(AZURE_ENV_NAME);
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 Service Layer Core
inputs:
azureSubscription: azconnection
scriptType: bash
scriptLocation: inlineScript
keepAzSessionActive: true
inlineScript: |
cd $(Build.SourcesDirectory)/ServiceLayer.AppHost;
ls -la;
azd deploy --no-prompt --environment $(AZURE_ENV_NAME);
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)
However, I still get the same error when the pipeline runs azd deploy: ERROR: failed deploying service 'account-service': failed executing template file: template: manifest template:27:19: executing "manifest template" at <securedParameter "CacheConnection">: error calling securedParameter: parameter CacheConnection not found I even added a step to echo out the contents of the environment variable, and all looks fine with it. I also tried creating the AZDO pipeline using azd pipeline config --provider azdo. It created the AZD_INITIAL_ENVIRONMENT_CONFIG variable for me, but I still get the same error . Deploying from the command line works fine btw.
18 Replies
Mąż Zuzanny Harmider Szczęście
it seems that the CacheConnection is missing
essenbee
essenbeeOP4w ago
But it isn't. Also, azd deploy from the command line works fine. I verified that the CacheConnection is defined in the JSON I put into the AZD_INITIAL_ENVIRONMENT_CONFIG environment variable
Mąż Zuzanny Harmider Szczęście
maybe its invalid?
essenbee
essenbeeOP4w ago
The step that echos out that variable clearly shows it is present Nope, as I say, deploying from the command line works fine. I even got azd to create the pipeline for me, using azd pipeline config --provider azdo and that created the variable automatically. That pipeline also fails with the exact same message So its something a bit deeper I fear
essenbee
essenbeeOP4w ago
This ask for help is not about connectivity to REDIS, sorry.
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
davidfowl
davidfowl4w ago
This is by far the most frustrating part
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
davidfowl
davidfowl4w ago
The way azd works with cd pipelines
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
essenbee
essenbeeOP4w ago
I'll see what I can do about making something visible to all, but its not an easy ask
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
essenbee
essenbeeOP4w ago
From the debugging I've done, it seems to me that azd provision and azd deploy ignore the contents of the env var AZD_INITIAL_ENVIRONMENT_CONFIG. I have verified that, even when that var is a pipeline secret, it does contain all the values needed. But azd just says they are not set... Here's a bit more information:
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)
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)
# 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.
essenbee
essenbeeOP4w ago
No description
essenbee
essenbeeOP4w ago
This issue is SOLVED! The problem was that I had run azd init and azd pipeline config in the AppHost folder. As soon as I ran those commands in the root of the solution, and adjusted the pipeline to remove the cd $(Build.SourcesDirectory)/ServiceLayer.AppHost; lines, it all worked like a charm 🙂
MODiX
MODiX4w ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?