YAML IIS web deploy deployment group - azure

I am following the tutorial for the IIS web deploy pipeline according to the docs on IIS Web App Deploy task
If you see the parameter list, there does not seems to have any deployment group parameter. Therefore, how do I know / control in which server that the result of the deployment goes?
- task: IISWebAppDeploymentOnMachineGroup#0
inputs:
webSiteName:
virtualApplication: # Optional
package: '$(System.DefaultWorkingDirectory)\**\*.zip'
setParametersFile: # Optional
removeAdditionalFilesFlag: false # Optional
excludeFilesFromAppDataFlag: false # Optional
takeAppOfflineFlag: false # Optional
additionalArguments: # Optional
xmlTransformation: # Optional
xmlVariableSubstitution: # Optional
jSONFiles: # Optional
I want it to deploy to my "Dev" group as per screenshot below. If YAML can't deploy to deployment group, where is the default deployment location (ie, which computer?)
Let's say that I want to deploy to my PC , how do I direct the deployment to go to my localbox and put it under C:/publish ?

As at June 2020 the YAML-based multistage pipeline does not support deployment groups. However, the YAML-based pipeline has an alternative: Environments.
You can create an Environment manually, under Azure Pipelines > Environments. Once you have created the Environment you can add Resources underneath it. At the moment there are only two types of resources supported: Kubernetes and Virtual Machines. The Virtual Machine resource type is a bit misleading: It can be a virtual machine but it can also be an on-prem physical server. If you're deploying to IIS you'll need to create a Virtual Machine resource.
Creating a Virtual Machine resource under an Environment is very much like adding a target to a Deployment Group: When you add the Virtual Machine resource to the Environment it will generate a PowerShell script that you copy to the target server and run there as administrator. Running that script will create a self-hosted agent on the target server and will register that agent as a Resource under the Environment.
This process is almost identical to the process of adding a target to a Deployment Group.
In the YAML file specify the environment under the deployment job. It's not enough to specify the environment by name. You have to also specify the resourceType for the Environment as well as the name.
Here is my YAML for the build and deployment stages:
trigger:
- master
stages:
- stage: 'Build'
displayName: 'Build the web application'
jobs:
- job: 'Build'
displayName: 'Build job'
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: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- stage: 'Deploy'
displayName: 'Deploy the web application'
dependsOn: Build
jobs:
- deployment: 'DeployToDev'
displayName: 'Deploy the web application to dev environment'
variables:
Parameters.IISDeploymentType: 'IISWebsite'
Parameters.ActionIISWebsite: 'CreateOrUpdateWebsite'
Parameters.WebsiteName: 'Default Web Site'
Parameters.WebsitePhysicalPath: '%SystemDrive%\inetpub\wwwroot\AspNetDemo'
Parameters.AddBinding: false
Parameters.VirtualPathForApplication: '/AspNetDemo'
Parameters.AppPoolName: ''
Parameters.VirtualApplication: 'AspNetDemo'
Parameters.Package: '$(Pipeline.Workspace)\drop\*.zip'
Parameters.RemoveAdditionalFilesFlag: true
Parameters.TakeAppOfflineFlag: true
Parameters.XmlTransformation: true
Parameters.XmlVariableSubstitution: true
environment:
name: Dev
resourceType: VirtualMachine
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: drop
- task: IISWebAppManagementOnMachineGroup#0
displayName: 'IIS Web App Manage'
inputs:
IISDeploymentType: '$(Parameters.IISDeploymentType)'
ActionIISWebsite: '$(Parameters.ActionIISWebsite)'
WebsiteName: '$(Parameters.WebsiteName)'
WebsitePhysicalPath: '$(Parameters.WebsitePhysicalPath)'
AddBinding: $(Parameters.AddBinding)
ParentWebsiteNameForVD: '$(Parameters.WebsiteName)'
VirtualPathForVD: '$(Parameters.VirtualPathForApplication)'
ParentWebsiteNameForApplication: '$(Parameters.WebsiteName)'
VirtualPathForApplication: '$(Parameters.VirtualPathForApplication)'
AppPoolName: '$(Parameters.AppPoolName)'
- task: IISWebAppDeploymentOnMachineGroup#0
displayName: 'IIS Web App Deploy'
inputs:
WebSiteName: '$(Parameters.WebsiteName)'
VirtualApplication: '$(Parameters.VirtualApplication)'
Package: '$(Parameters.Package)'
RemoveAdditionalFilesFlag: $(Parameters.RemoveAdditionalFilesFlag)
TakeAppOfflineFlag: $(Parameters.TakeAppOfflineFlag)
XmlTransformation: $(Parameters.XmlTransformation)
XmlVariableSubstitution: $(Parameters.XmlVariableSubstitution)
Note the environment information in the deployment stage, specifying the name (Dev) and the resourceType (VirtualMachine):
environment:
name: Dev
resourceType: VirtualMachine

YAML does not support deployment groups. If you want to use deployment groups, you can't use YAML.

Daniell is right, It seems at this moment YAML can't do the release to deployment group The workaround is as below:
add the following code in the build:
task: PublishPipelineArtifact#1
inputs:
targetPath: '$(Pipeline.Workspace)'
publishLocation: 'pipeline'
task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
task: ArchiveFiles#2
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
and then you can go to the release , use iis web deploy, ensure that the correct artefact is used in step 1 and choose your package folder. You should be able to see the artifact that you built.

Related

Azure Pipeline refuses to deploy from zip instead calling from blob which doesn't exist

Very much still new to YAML, but i've showed this to a colleague who's equally confused as me. I've built a CI/CD pipeline, and the CI end seems to work just fine. The pipeline claims its deploying a function app successfully, but when I go to check, there's nothing in the function app, and the output code from the pipeline seems to be calling from a blob storage folder that doesn't exist. We can't work out how to change the behaviour of it.
Is this something anyone has seen before?
This is the YAML:
# Python Function App to Linux on Azure
# Build a Python function app and deploy it to Azure as a Linux function app.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/python
trigger:
- master
variables:
# Azure Resource Manager connection created during pipeline creation
azureSubscription: 'ab1c86d0-0d0c-4029-913b-e5483df967b2'
# Function app name
functionAppName: 'categoriserfunctionapp'
# Agent VM image name
vmImageName: 'ubuntu-latest'
# Working Directory
workingDirectory: ''
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- bash: |
if [ -f extensions.csproj ]
then
dotnet build extensions.csproj --runtime ubuntu.16.04-x64 --output ./bin
fi
workingDirectory: $(workingDirectory)
displayName: 'Build extensions'
- task: UsePythonVersion#0
displayName: 'Use Python 3.6'
inputs:
versionSpec: 3.6 # Functions V2 supports Python 3.6 as of today
architecture: 'x64'
- bash: |
pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
workingDirectory: $(workingDirectory)
displayName: 'Install application dependencies'
- task: ArchiveFiles#2
displayName: 'Archive files'
inputs:
rootFolderOrFile: "$(System.DefaultWorkingDirectory)"
includeRootFolder: false
archiveType: zip
archiveFile: "$(System.DefaultWorkingDirectory)/$(Build.BuildId).zip"
replaceExistingArchive: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/$(Build.BuildId).zip'
artifactName: 'drop'
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: 'test'
pool:
vmImage: 'windows-latest'
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact#2
displayName: 'Download Pipeline Artifact'
inputs:
buildType: 'current'
artifactName: 'drop'
targetPath: '$(Pipeline.Workspace)/drop/'
- task: AzureFunctionApp#1
inputs:
azureSubscription: 'Visual Studio Enterprise Subscription – MPN (f1f3e234-557b-4acd-b353-2ff89c547e49)'
appType: 'functionAppLinux'
appName: 'categoriserfunctionapp'
package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
runtimeStack: 'PYTHON|3.9'
And this is the output from the CD end:
2022-09-27T15:59:26.6330661Z ##[section]Starting: AzureFunctionApp
2022-09-27T15:59:26.6442433Z ==============================================================================
2022-09-27T15:59:26.6442718Z Task : Azure Functions
2022-09-27T15:59:26.6443009Z Description : Update a function app with .NET, Python, JavaScript, PowerShell, Java based web applications
2022-09-27T15:59:26.6443282Z Version : 1.208.2
2022-09-27T15:59:26.6443454Z Author : Microsoft Corporation
2022-09-27T15:59:26.6443686Z Help : https://aka.ms/azurefunctiontroubleshooting
2022-09-27T15:59:26.6443957Z ==============================================================================
2022-09-27T15:59:27.4092341Z Got service connection details for Azure App Service:'categoriserfunctionapp'
2022-09-27T15:59:30.9793711Z Trying to update App Service Application settings. Data: {"WEBSITE_RUN_FROM_PACKAGE":"https://categoriserfunc9c44.blob.core.windows.net/azure-pipelines-deploy/package_1664294369833.zip?***"}
2022-09-27T15:59:32.4412565Z Updated App Service Application settings.
2022-09-27T15:59:32.4414182Z Updated WEBSITE_RUN_FROM_PACKAGE Application setting to https://categoriserfunc9c44.blob.core.windows.net/azure-pipelines-deploy/package_1664294369833.zip?***
2022-09-27T15:59:37.4527980Z Syncing triggers for function app
2022-09-27T15:59:39.3782043Z Sync triggers for function app completed successfully
2022-09-27T15:59:41.0691225Z Successfully added release annotation to the Application Insight : categoriserfunctionapp
2022-09-27T15:59:41.3968439Z App Service Application URL: https://categoriserfunctionapp.azurewebsites.net
2022-09-27T15:59:41.4063927Z ##[section]Finishing: AzureFunctionApp
We tried changing the hardcode of WEBSITE_RUN_FROM_PACKAGE but it seems to have changed itself back since I refreshed the function app.
Does anyone have any ideas for fixing this?
I can successfully deploy to azure function app with a slight modification based on the YAML you provided.
trigger:
- none
variables:
# Azure Resource Manager connection created during pipeline creation
azureSubscription: '<ARM Service Connection Name>'
resourceGroupName: '<Resource Group Name of storage>'
# Function app name
functionAppName: '<Your Function App Name>'
# Agent VM image name
vmImageName: 'ubuntu-latest'
# Working Directory
workingDirectory: ''
storage_str: 'DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx;EndpointSuffix=core.windows.net'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: UsePythonVersion#0
displayName: 'Use Python 3.9'
inputs:
versionSpec: 3.9 # Functions V2 supports Python 3.6 as of today
architecture: 'x64'
- bash: |
pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
workingDirectory: $(workingDirectory)
displayName: 'Install application dependencies'
- task: ArchiveFiles#2
displayName: 'Archive files'
inputs:
rootFolderOrFile: "$(System.DefaultWorkingDirectory)"
includeRootFolder: false
archiveType: zip
archiveFile: "$(System.DefaultWorkingDirectory)/$(Build.BuildId).zip"
replaceExistingArchive: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/$(Build.BuildId).zip'
artifactName: 'drop'
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: 'test'
pool:
vmImage: 'windows-latest'
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact#2
displayName: 'Download Pipeline Artifact'
inputs:
buildType: 'current'
artifactName: 'drop'
targetPath: '$(Pipeline.Workspace)/drop/'
- task: AzureAppServiceSettings#1
inputs:
azureSubscription: '$(azureSubscription)'
appName: '$(functionAppName)'
resourceGroupName: '$(resourceGroupName)'
appSettings: |
[
{
"name": "AzureWebJobsStorage",
"value": "$(storage_str)",
"slotSetting": false
}
]
- task: AzureFunctionApp#1
inputs:
azureSubscription: '$(azureSubscription)'
appType: 'functionAppLinux'
appName: '$(functionAppName)'
package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
runtimeStack: 'PYTHON|3.9'
From your description, the blob file doesn't exist? If so, the function will not execute successfully.
You must make sure there is a file to use for 'run from package'.
There are several problems with your YAML which may cause the issue:
Variables in YAML are not fully used. The service connection and variable definitions in the Deployment stage are different (I have changed to the same).
The python version used is different from the azure function app version (I have changed to the same).
By the way, In order to rule out the problem that the storage is controlled by some policy or program, you can create a new storage to test and provide the connection string in the above YAML file (the location of the package your function app is based on is determined by AzureWebJobsStorage, the above YAML can be Change settings before actual deployment.).
And additional, if you can deploy the function app with no problem on local(such as VS Code), then you can use something like below to deploy the function app.
trigger:
- none
variables:
- name: System.debug
value: true
pool:
VMAS #agent based on your local machine.
steps:
- task: AzurePowerShell#5
inputs:
azureSubscription: 'xxx'
ScriptType: 'InlineScript'
Inline: 'func azure functionapp publish xxx --build remote'
azurePowerShellVersion: 'LatestVersion'
My repo structure likes below:

Troubles deploying my API to Azure App Service

I'm developing a very simple API in ASP.NET Core for testing purposes.
I have an endpoint at https://localhost:5678/api/Values/addition/{a}/{b} which just adds number A and B and stores the result in a database.
The database is stored on Azure. In local, the application is running well and connects to my Azure SQL Server database successfully. I have hardcoded the connection string to avoid any complexifications which can result in errors. I'll change it later.
I have also created a Release Pipeline on Azure. First, here is the azure-pipelines.yml :
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
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:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
The release pipeline is triggered whenever a new push is detected on the master branch :
The job triggered is quite simple, it has a Run On Agent which triggers the deployment of my application to an Azure App Service like that :
steps:
- task: AzureRmWebAppDeployment#4
displayName: 'Deploy To Development'
inputs:
azureSubscription: '{MY SUBSCRIPTION ID}'
appType: webAppLinux
WebAppName: '{MY APP SERVICE NAME}'
deployToSlotOrASE: true
ResourceGroupName: '{MY RESOURCEGROUP NAME, SAME AS THE APP SERVICE}'
The build is successful, all jobs run successfully.
I can now navigate to my app service url https://{MY APP SERVICE NAME}.azurewebsites.net and get the welcome page of Azure :
I assume that at this point, I should be able to navigate to https://{MY APP SERVICE NAME}.azurewebsites.net/api/Values/addition/{a}/{b} and get a response from my API but instead of it, I get an error 404. The api endpoint just doesn't exist.
I've hardcoded everything to avoid system errors like non-acccessible external service, my log stream is also empty, and finally I've used kudu to verify that I have a correct web.config on my application. Everything is, I think, well published.
What am I missing here ?
EDIT 1 :
I've modified my Pipeline as following :
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: ubuntu-latest
variables:
buildConfiguration: 'Release'
steps:
- task: DotNetCoreCLI#2
inputs:
command: 'test'
projects: '**/*Tests.csproj'
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI#2
inputs:
command: 'restore'
projects: '**/*sln'
feedsToUse: 'select'
vstsFeed: '{MY FEED}'
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: false
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: true
modifyOutputPath: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
It modified my wwwroot/ of the App Service, but it still doesn't work.
I don't think you're actually pushing the zip to the app service (which would explain the 404). The AzureRmWebAppDeployment#4 task you're using requires a Package or packageForLinux parameter if you use the webAppLinux type (scroll down a bit from here), so that it knows what to publish to your app service.

Azure DevOps - Deployment problems

I am trying to deploy a new code in an existing function on Azure but for some reason I am getting a Green/Pass pipeline but when I request the URL I got error 404.
What I have done:
Setup the function manually
Run a Pipeline with the stages:
a) mvn package
b) zip content of azure functions in the target
c) Deploy artifact from agent to the pipeline
d) Deploy artifact into a function using snipped code from microsoft.
The pipeline gets a green state and the function has been deployed:
Starting: AzureFunctionApp
==============================================================================
Task : Azure Functions
Description : Update a function app with .NET, Python, JavaScript, PowerShell, Java based web applications
Version : 1.195.0
Author : Microsoft Corporation
Help : https://aka.ms/azurefunctiontroubleshooting
==============================================================================
Got service connection details for Azure App Service:'test'
Trying to update App Service Application settings. Data: {"WEBSITE_RUN_FROM_PACKAGE":"https://teststorage.blob.core.windows.net/azure-pipelines-deploy/package_1639741028399.zip?***"}
Updated App Service Application settings.
Updated WEBSITE_RUN_FROM_PACKAGE Application setting to https://teststorage.blob.core.windows.net/azure-pipelines-deploy/package_1639743928399.zip?***
Syncing triggers for function app
Sync triggers for function app completed successfully
Successfully added release annotation to the Application Insight :test
App Service Application URL: http://test.azurewebsites.net
Finishing: AzureFunctionApp
but when I request the URL it fails, also I check the functions section in the portal , and the function that was there (deployed manually) got removed.
Note:
The code is fine because I can deploy manually the same code and it is working fine, via pipeline is not working.
Pipeline code:
pool:
vmImage: ubuntu-latest
variables:
serviceName: test
jdkVersion: "1.11"
stages:
- stage:
displayName: Build
jobs:
- job: "Deployment_draft"
steps:
- task: MavenAuthenticate#0
displayName: "Maven Authenticate"
inputs:
artifactsFeeds: test-artifactory
- task: ArchiveFiles#2
inputs:
rootFolderOrFile: $(Build.SourcesDirectory)/${{ variables.serviceName }}/target/azure-functions/${{ variables.serviceName }}
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: '${{ variables.serviceName }}'
publishLocation: 'Container'
- task: AzureFunctionApp#1
inputs:
azureSubscription: 'SubscriptionTest(Subscription ID)'
appType: 'functionAppLinux'
appName: 'test'
deploymentMethod: zipDeploy
package: '$(Build.ArtifactStagingDirectory)/**/*.zip'
rootFolderorFile - Enter the root folder or file path to add to the archive. If a folder, everything under the folder will be added to the resulting archive. Default value: $(Build.BinariesDirectory)
I have slightly modified your pipeline.
pool:
vmImage: ubuntu-latest
variables:
serviceName: test
jdkVersion: "1.11"
stages:
- stage:
displayName: Build
jobs:
- job: "Deployment_draft"
steps:
- task: MavenAuthenticate#0
displayName: "Maven Authenticate"
inputs:
artifactsFeeds: test-artifactory
- stage : deploy
jobs:
- job:
displayName : Function App update
steps:
- task: ArchiveFiles#2
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
ArtifactName: '${{ variables.serviceName }}'
publishLocation: 'Container'
- task: AzureFunctionApp#1
inputs:
azureSubscription: 'SubscriptionTest(Subscription ID)'
appType: 'functionAppLinux'
appName: 'test'
deploymentMethod: zipDeploy
package: '$(Build.ArtifactStagingDirectory)/**/*.zip'
Refer here

Unable to Publish the project from Azure DEVOPS

I am new for azure devops and learning purpose create new basic account from azure. I created new projects and did require changes. This project publishing the code into azure VM and it's giving error in final step.
Step: IIS Web App Deploy
Error: No package found with specified pattern.Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
YAML for Release:
steps:
- task: IISWebAppManagementOnMachineGroup#0
displayName: 'IIS Web App Manage'
inputs:
IISDeploymentType: '$(Parameters.IISDeploymentType)'
ActionIISWebsite: '$(Parameters.ActionIISWebsite)'
WebsiteName: '$(Parameters.WebsiteName)'
WebsitePhysicalPath: '%SystemDrive%\inetpub\wwwroot\DD'
AddBinding: '$(Parameters.AddBinding)'
Bindings: '$(Parameters.Bindings)'
CreateOrUpdateAppPoolForWebsite: true
AppPoolNameForWebsite: DD
ParentWebsiteNameForVD: '$(Parameters.WebsiteName)'
VirtualPathForVD: '$(Parameters.VirtualPathForApplication)'
ParentWebsiteNameForApplication: '$(Parameters.WebsiteName)'
VirtualPathForApplication: '$(Parameters.VirtualPathForApplication)'
AppPoolName: '$(Parameters.AppPoolName)
steps:
- task: IISWebAppDeploymentOnMachineGroup#0
displayName: 'IIS Web App Deploy'
inputs:
WebSiteName: '$(Parameters.WebsiteName)'
Package: '$(System.DefaultWorkingDirectory)/_ABC.API/drop/*.zip'
RemoveAdditionalFilesFlag: true
TakeAppOfflineFlag: true
XmlVariableSubstitution: True
Build YAML:
trigger:
- master
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: CopyFiles#2
inputs:
SourceFolder: '$(agent.builddirectory)'
Contents: |
|
**\*.runsettings
**\*FunctionalTest*\**\bin\$(BuildConfiguration)\**
TargetFolder: '''$(build.artifactstagingdirectory)\FunctionalTests'''
- task: PublishBuildArtifacts#1
inputs:
artifactName: 'drop'
pathToPublish: '$(build.artifactStagingDirectory)'
Error Logs:
2020-04-19T10:02:47.0130907Z ##[section]Starting: IIS Web App Deploy
2020-04-19T10:02:47.0236460Z ==============================================================================
2020-04-19T10:02:47.0236816Z Task : IIS web app deploy
2020-04-19T10:02:47.0237124Z Description : Deploy a website or web application using Web Deploy
2020-04-19T10:02:47.0237414Z Version : 0.156.9
2020-04-19T10:02:47.0237649Z Author : Microsoft Corporation
2020-04-19T10:02:47.0238051Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/iis-web-app-deployment-on-machine-group
2020-04-19T10:02:47.0238500Z ==============================================================================
2020-04-19T10:02:47.8446908Z ##[error]Error: No package found with specified pattern.<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
2020-04-19T10:02:47.8471615Z ##[section]Finishing: IIS Web App Deploy
Please help to find the issue
Trying to change the section Package to use the path from pathToPublish by default it was System.DefaultWorkingDirectory.
- task: PublishBuildArtifacts#1
inputs:
artifactName: 'drop'
pathToPublish: '$(build.artifactStagingDirectory)'
Change in IISWebAppDeploymentOnMachineGroup task:
- task: IISWebAppDeploymentOnMachineGroup#0
displayName: 'IIS Web App Deploy'
inputs:
WebSiteName: '$(Parameters.WebsiteName)'
Package: '$(build.artifactStagingDirectory)/*.zip'
RemoveAdditionalFilesFlag: true
TakeAppOfflineFlag: true
XmlVariableSubstitution: True
Build.ArtifactStagingDirectory :
The local path on the agent where any artifacts are copied to before being pushed to their destination. For example: c:\agent_work\1\a
System.DefaultWorkingDirectory :
The local path on the agent where your source code files are downloaded. For example: c:\agent_work\1\s
For this ,please refer to predefined variables.

Azure DevOps Doesn't Publish Web App from ZIP Deploy, Runs It as Read-Only ZIP Package Instead

We have an Azure DevOps Pipeline that runs our application as ZIP package https://learn.microsoft.com/en-us/azure/app-service/deploy-run-package
as opposed to ZIP Deploy. So we are not able to SFTP into our Web App and change something. Why does the Pipeline runs our application as ZIP package and how can we change this?
This is the Pipeline:
trigger: none
pool:
vmImage: 'windows-latest'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: 'Solution1.sln'
- task: VSBuild#1
inputs:
solution: '$(agent.builddirectory)\s\Folder\Project.csproj'
msbuildArgs: '/p:OutputPath="$(build.binariesDirectory)\Folder\bin" /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:SkipInvalidConfigurations=true /p:publishUrl="$(build.artifactStagingDirectory)\ProjectTempFolder"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: CopyFiles#2
inputs:
SourceFolder: '$(build.artifactStagingDirectory)\ProjectTempFolder'
Contents: |
**
TargetFolder: '$(build.ArtifactStagingDirectory)\ProjectArtifacts'
- task: ArchiveFiles#2
inputs:
rootFolderOrFile: '$(build.ArtifactStagingDirectory)\ProjectArtifacts'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(build.ArtifactStagingDirectory)\Project.zip'
replaceExistingArchive: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(build.ArtifactStagingDirectory)\Project.zip'
- task: AzureRmWebAppDeployment#4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'Subscription1'
appType: 'webApp'
WebAppName: 'CoolWebApp777'
packageForLinux: '$(build.ArtifactStagingDirectory)\Project.zip'
Why does the Pipeline runs our application as ZIP package and how can we change this?
It seems you want to disable to run your Web App from a package, AFAIK, the default version in the release pipeline is now set to Version 4. This version has the "Select deployment method" checkbox disabled, which in turn, allows the "Run as Package" feature by default as well. To change this value, go into the "Deploy Azure App Service" task for each environment and expand Additional Deployment Options. You’ll probably want to change it most often to Web Deploy:
Besides, you can turn that off by deleting the WEBSITE_RUN_FROM_ZIP or WEBSITE_RUN_FROM_PACKAGE application setting in the portal.
Note this will clear your web app until the next time you publish.
Hope this helps.

Resources