I am using azure web apps with VSTS to build and deploy my web app.
All works great but I recently aded an extension to the web app, via Azure, which adds dll's to the site.
Now when I do a deployment, the deployment fails as the files are locked (by deployment, I should say 'Release').
One thing I am wondering, is it possible to exclude the folder from being copied over in the release? There's no need to copy the files anyway, and they're a seperate sub folder to the main dll's.
Thanks!
You can exclude the folder by specifying ExcludeFoldersFromDeployment property, then the folder will be excluded during deploy/publish to the package, then deploy the package to the azure app service through Azure App Service Deploy task directly.
For example: MSBuild argument of Visual Studio Build task:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\" /p:ExcludeFoldersFromDeployment="[folder path that relative to project file]"
Related
I have a Visual Studio Solution which has multiple websites projects.
I'm currently running a build in VSTS against 1 repository which is creating a drop.zip artifact that has produced 3 websites segmented by their project/folder name.
Now I'd like to have 3 release definitions which publish each of the respective folders to Azure App Service.
How can this be done?
Inside of the Azure App Service Release step, I can only point to a single Zip file. I need to point to a folder inside the Zip the file, correct?
You could create a zip for each of you 3 websites. Publish the websites separately to 3 different build artifacts in the build pipeline.
In the release definition add all 3 artifacts in the artifacts section and deploy them to their respective Azure App service.
It does not must be a zip file. Just as the high-lighted section in your screenshot. It could be a package file or folder.
So for your scenario, you just need to configure the 3 release definition to link to the same build artifact. And then in the release definition add two tasks:
Extract files Task - Use this task to extract the zip file
Azure App Service Deploy Task - In this task, set "Package or folder" path to the extracted project folder.
I was able to get this working by using the following MSBuild configuration:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=false /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)" /p:DeployIisAppPath="Default Web Site" /p:Configuration=Release /p:Platform="Any CPU"
This generated a separate Zip file for each Web App in the solution.
I have a simple MVC application. In VSTS, build is success and release to Azure WebApp is also success. But azure url doesn't work. Application runs & works in local. Azure WebApp also looks good. Not sure if its issue with Azure or VSTS Release pipeline. IS Azure WebApp capable of running MVC applications?
My VSTS release pipe-line:
First, the MVC application (MVC template project in Visual Studio) can be run on Azure Web App.
Secondly, the App Service URL option of Azure App Service Deploy task Provide a name, like FabrikamWebAppURL for the variable for the AzureRM Web App Hosted URL. The variable can be used as $(variableName), like $(FabrikamWebAppURL) to refer to the Hosted URL of the AzureRM Web App in subsequent tasks, such as PowerShell.
Thirdly, you can refer to these steps below to build and deploy application:
NuGet Tool Installer (Version of NuGet.exe to install: 4.3.0)
NuGet restore
Visual Studio Build (MSBuild Arguments: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)")
Publish Build Artifacts (Path to publish: $(build.artifactstagingdirectory))
Create a new release definition
Azure App Service Deploy (Package or folder: $(System.DefaultWorkingDirectory)/**/*.zip)
Is there a way of having my Azure WebJob automatically deploy without needing to right click and select "Publish as Azure WebJob" every time? i.e. when I check-in my solution it is automatically deploy to the Azure Portal webjob section
While I tried to accomplish this, I found out that there is no tooling support for dotnet core projects as of now. The proposed webjobs.props/ msbuild solutions are all dotnet framework specific.
However I also found out that a webjob can be anything that's executable on the local machine (could be node.js or just a batch command).
The key is to understand how WebJobs are recognized by the host:
A WebJob on a Windows host is (by what I gathered from experimenting with it) just a run.cmd file that contains instructions on how to start the webJob. For dotnet core that would be dotnet MyDll.dll %* (%* to pass arguments for output redirection etc. down from the host).
Now depending on wether the job is continuous or triggered the run.cmd file needs to be located either at app_data/jobs/continuous/[NameOfJob] or app_data/jobs/triggered/[NameOfJob]. For the triggered job you could also add a schedule using a settings.job file like described here.
If there is a run.cmd at the proper location it will be recognized as a WebJob
Now to deploy a webjob using VSTS regardless of the runtime framework follow these steps:
Build/Publish your WebJob if necessary to get the executables
Add a run.cmd file next to your webjob executables that contains the proper startup instructions. You could also add settings.job here if needed.
Create the folder hierarchy app_data/jobs/[triggered/continuous]/[nameOfJob] and copy your executables into the lowest folder. Make sure run.cmd is directly under the [nameOfJob]/ directory
Zip the app_data folder so that the zip-package contains the entire hierarchy
Publish your zip file using the normal Azure App Service Deployment task (just like deploying the web app)
And that's it.
Yes you can.
Brady Gaster has written about this on a blog post (haven't tried it myself).
From what I gather, the TL;DR; summary is the following:
add a file named webjobs.props to the properties folder of the Web Application Project or Console Application you’re publishing
After that, edit the file so the ManagementCertificate, SubscriptionId and PublishSettingsPath are filled with correct data.
Now you should be able to publish the files using the command
msbuild WebJobDemo.Web.csproj /p:DeployOnBuild=true /p:PublishProfile=WebJobDemo /p:VisualStudioVersion=12.0 /p:Password=asdfasdf
(Note, post is written for VS2013)
Afterwards you should see something like this.
You could of course automate this in VSTS (or any other build/deployment tool for that matter) whenever something is checked in to your repository.
A (rather complete) answer on how to do this in VSTS via the command-line can be found in this answer: https://stackoverflow.com/a/45703975/352640
You can do it through Continuous Integration Build (trigger the build once check in).
Regarding deploy WebJob, you can generate a package through Visual Studio Build task with /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.stagingDirectory)" argument.
Then deploy it through Azure App Deployment task.
More information: Deploying and Schedule Azure WebJobs from VSTS to Azure Web App
In Visual Studio in order to enable automatic WebJobs deployment together with a Web project right-click the Web project in Solution Explorer, and then click: Add > Existing Project as Azure WebJob and create your WebJob.
More details can be found in an article by MS - webjobs-dotnet-deploy-vs
We have several Build definitions setup at TFS online (visualstudio.com) which delivers our Web application to several Azure machines (DEV, TEST, AccTest etc..).
It works and they trigger on build events.
BUT: Now we have added a Console Application (Batch exe file) that don't have a publishingProfile. The Build definition builds entire solution (console project is a part of that), but when it comes to Deployment only Web project is deployed in another folder and zipped.
I have read a lot on Stackoverflow and MSDN sites. But could not really find any spot on answers. This must be a common scenario that you have non-web projects in a solution that also needs to be deployed on same server through VSTS.
You can archive the files you want to deploy as a zip file, and specify the zip file as Package or folder option in Azure App Service Deploy task.
Detail tasks and settings to deploy the .net console app to azure as below:
1. Copy Files task
Source Folder: $(System.DefaultWorkingDirectory)
Contents: ProjectName\** or you can specify the certain file (such as *.exe) to copy
Target Folder: $(Build.ArtifactStagingDirectory)
2. Archive Files
Root folder (or file) to archive: $(Build.ArtifactStagingDirectory)
Archive type: zip
Archive file to create: $(Build.ArtifactStagingDirectory)/deploy.zip
3. Azure App Service Deploy
Specify Azure subscription and App Service name as you set before.
Package or folder: $(Build.ArtifactStagingDirectory)\deploy.zip
Now files you copied from .net console project are deployed to your Azure App service.
I'm having some trouble deploying an Azure Web Service using the new Team Build that is available at Visual Studio Online. When the solution have been built successfully, the deployment task tries to find the CsPkg and the CsCfg, which fails.
How do I specify the "Path of CsPkg/CsCfg under the default artifact directory" that is required? Do I have to specify some MSBuild arguments?
You can use the $(build.stagingDirectory) variable in the CsPkg/CsCfg fields. This will be the root of your repo. Your binaries will be at some location under there. E.g. $(build.stagingDirectory)\*.cspkg and
$(build.stagingDirectory)\*.cscfg
There's a huge list of built-in variables on MSDN.
You may also have to build your cloud service project with the MSBuild argument /t:Publish
I just checked: If you use the "Cloud Service" deployment template, all of this stuff is automatically filled in for you, including the paths.