essenbee
essenbee
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
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 🙂
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
No description
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
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.
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
# 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)
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
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)
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
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:
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
I'll see what I can do about making something visible to all, but its not an easy ask
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
This ask for help is not about connectivity to REDIS, sorry.
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
So its something a bit deeper I fear
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
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
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
Nope, as I say, deploying from the command line works fine.
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
The step that echos out that variable clearly shows it is present
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
I verified that the CacheConnection is defined in the JSON I put into the AZD_INITIAL_ENVIRONMENT_CONFIG environment variable
30 replies
CC#
Created by essenbee on 1/28/2025 in #help
✅ Can't Deploy .NET Aspire application using azd in Azure DevOps Pipeline
But it isn't. Also, azd deploy from the command line works fine.
30 replies