VSTS deployment to multiple app services

1.8k Views Asked by At

I am using VSTS with TFS repository for hosting my code. The solution is a Asp.Net core solution and contains couple of projects. I have two projects in the solution that goes to different App Services - one will be deployed to a Web App and other to an API App.

Question is how do I configure a single build definition / release definition that deploys these artifacts. Currently, I have two definitions - one for each and I would like to have one. How can I go about configuring this?

2

There are 2 best solutions below

3
starian chen-MSFT On BEST ANSWER
  1. You can create publish profile (right click a project => Publish) with the same name for these projects (relative path for package location, such as <DesktopBuildPackageLocation>..\..\a\WebApp</DesktopBuildPackageLocation>). With this way, the web app published result will be in different folders.
  2. Specify MSBuild Arguments of Visual Studio Build task will be like this: /p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:PublishProfile="[profile name]".
  3. Add Publish Build Artifacts to publish these web app published result (e.g. Path to Publish:$(build.artifactstagingdirectory))
  4. Create a new release definition
  5. Add two Deploy app tasks (e.g. Azure app service deploy)
  6. Specify corresponding package to deploy

Update:

Using multiple Publish Tasks to publish each package is ok too (Do not need the publish profile).

0
KierenH On
  1. Start with the "ASP.NET Core (.NET Framework)" Build Template. By default, a single package is created for all Function Apps in the solution.
  2. Modify the Build Solution task msbuild arguments so that a package is created for each Function App projects

    From:
    /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:SkipInvalidConfigurations=true /p:PackageAsSingleFile=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"

    To
    /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)" /p:DeployIisAppPath="Default Web Site"

  3. Run the build and review the publish artifacts, you should see multiple zip files in the package, one for each of the Function Apps

  4. Now, for each Function App you want to deploy, add an 'Deploy Azure App Service' task to your Release definition

  5. Update the 'Deploy Azure App Service' task, package or folder, to:
    $(System.ArtifactsDirectory)/**/Your.Project.FunctionApp.zip