I've been trying to deploy a .NET 8 web app into Azure by taking advantage of Azure DevOps CI/CD pipelines. This is essentially related to this post but redid the deployment as not many things are connected or live in production yet.
I redid app service and pipelines to get CI/CD up and running, however, I'm getting an error that my web app failed to deploy. As shown below:
##[error]Failed to deploy web package to App Service.
##[warning]Can't find loc string for key: KuduStackTraceURL
##[error]KuduStackTraceURL https://$<my-resource>:***@<my-resource>.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace
##[error]Error: Error: Failed to deploy web package to App Service. Internal Server Error (CODE: 500)
I have added WEBSITE_WEBDEPLOY_USE_SCM in my environment variables in App Service as my investigation led me to this, but, no change in the error. Another solution was to go Kudo and remove the Deployments folder, but no change on the error either.
This is my current YAML file in the pipeline.
trigger:
- development
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: true
arguments: '--configuration $(buildConfiguration)'
zipAfterPublish: true
# - task: PublishBuildArtifacts@1
# inputs:
# PathtoPublish: '$(Build.ArtifactStagingDirectory)'
# ArtifactName: 'drop'
# publishLocation: 'Container'
- task: AzureWebApp@1
inputs:
azureSubscription: '<My service Connection>'
appType: 'webApp'
appName: '<App-Name>'
deployToSlotOrASE: true
resourceGroupName: '<ResourceGroup>'
slotName: 'production'
package: '$(System.DefaultWorkingDirectory)/**/*.zip'
appSettings: '-WEBSITE_RUN_FROM_PACKAGE 1'
deploymentMethod: 'auto'
My question is what am I missing here to get it deployed in azure? The web App will be consuming Azure SQL DB, Key Vaults, and Blob Storage. I don't think these should affect the piepline but I'm still kinda green in this space.
As a reference this was my old pipeline.
trigger:
- development
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: true
arguments: '--configuration $(buildConfiguration)'
zipAfterPublish: true
- task: AzureWebApp@1
inputs:
azureSubscription: '<My Subscription>'
appType: 'webApp'
appName: '<My Resource>'
package: '$(System.DefaultWorkingDirectory)/**/*.zip'
appSettings: '-WEBSITE_RUN_FROM_PACKAGE 1'
deploymentMethod: 'auto'
I found a solution by following the link below. It appears that in the portal I should disconnect the repo in Deployment Center and re-run the pipeline. Once it gives a check mark then connect it again.
https://learn.microsoft.com/en-us/answers/questions/382358/when-deploy-functionapp-to-slot-)-error-package-de