Error Deploying to Azure in Build pipeline - azure

I'm working on creating a build pipeline that to compile an ApiWebApp and deploy it to Azure from Visual Studio Online. My build flow is:
Visual Studio Build
Publish Build Artifacts
Azure Web App Deployments
My questions are:
Is it reasonable to deploy an API App from Visual Studio Online to Azure?
Hoping the answer to this is yes.
Do I have the right steps in my pipeline?
In the Azure Web App Deployments step, what should I enter for the 'Web Deploy Package' ?

Yes, it is reasonable, and you have the right build steps in your build definition.
You need to have a check on this blog, it describes the details on how to deploy an Azure Web Site using the new build system in Visual Studio Online.
Here are some important steps I would like to highlight from there:
Firstly, you need to register your Azure subscription in TFS.
Secondly, in the Visual Studio Build step, pass the following argument to MSBuild: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.stagingDirectory)" These specific settings will create a web deploy package and put it in the staging directory of the build definition.
Thirdly, in the Azure Web App Deployment step, set Web Deploy Package $(build.stagingDirectory)\projectname.zip.

Yes it is reasonable.
Here are the steps:
Step 1: Create a team project
Step 2: Check in a project to source control
Step 3: Connect the project to Azure (In azure portal)
Step 4: Trigger a rebuild and redeploy your project
Here is a complete steps on how you can do it:
https://azure.microsoft.com/en-us/documentation/articles/cloud-services-continuous-delivery-use-vso/
In the package text box you can enter:
($build.stagingDirectory)YourProjectName.zip

Related

how to make azure devops release pipeline click once

I have a simple executable, that I have build and unittested in a build pipeline.
now I want to install it on some test machines and run some tests on the app, before releasing it to production. (eventually I hope to automate the tests with specflow, but that is the next step)
So basically I have an helloworld.exe build, that I want to be installed from a pipeline to at test agent computer.
I think clickonce is the optimal option, but am unsure how to set it up on azure devops. (we use a server on premises)
Msbuild has Publish target to build and publish the ClickOnce application. It will generate the setup.exe you want. Please check document: Create and build a basic ClickOnce application with MSBuild. In release pipeline you can use msbuild task or Visual Studio Task with Publish target(/t:Publish as argument).
Then you'll get one app.publish folder where the files you want exist there:
This folder can be used for your further deployment.
Here is a ticket you can refer to .
In addition, azure devops Marketplace provides some extension: ClickOnce Packager, ClickOnceMore DevOps Pipeline Task.

VSTS release to azure succeeded but url doesn't work

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)

How to deploy Azure WebJob as part of automatic VSTS deployment

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

Is there anyway to import a publish profile directly into Team Services Build Definition for .NET Core

I have a .NET Core application that I have configured Continuous Integration with through the Azure deployment wizard.
This process created a build definition inside of my team services that I have configured to build and deploy on check in of source code.
The code builds and deploys successfully but I am having trouble getting database changes through migrations to be executed as part of CI. I have downloaded the publish profile from Azure for the web application and imported it into Visual Studio. I could then edit the publish setting to include running migrations on publish as you can see below.
When I run this manually from Visual Studio it publishes successfully and also executes the migration script.
So I am wondering is there a way to import this edited and working publish profile into my Team Services Continuous Integration?
Try to use Visual Studio Build step with arguments of /p:DeployOnBuild=true /p:PublishProfile="[your publish profile]" instead.
Modify publish profile file to add Password and AllowUntrustedCertificate nodes. (refer to: Publish an Azure Web Site from the Command Line)
Add /p:DeployOnBuild=true /p:PublishProfile="[your publish profile]" arguments to Visual Studio Build task.

How to deploy azure webjob automatically via VS Team Services - release

I want to deploy azure webjob using build and release management of visual studio team services.
I have created a webjob project and I already deployed from visual studio and I am looking to make the deployment automatic.
Thank you!
Refer to these steps to publish/deploy web job:
Open VS 2015 and create a Web Job project (e.g. WebJob1)
Right click the project > Publish As Azure WebJob, then it will create webjob-publish-settings.json file (This is required)
Create a build definition, steps:
NuGet Installer (Path to solution or packages.config: **\*.sln; Installation type: Restore)
Visual Studio Build (Solution: **\*.sln, MSBuild Arguments: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\")
Publish Build Artifacts (Path to Publish: $(build.artifactstagingdirectory); Artifact Name: drop; Artifact Type: Server)
Queue build
Create a release definition and link to that build definition(Artifacts tab), tasks:
Azure App Service Deploy (Specify Azure Subscription and App Service name; Package or Folder: $(System.DefaultWorkingDirectory)\**\WebJob1.zip
Create a new release
On the other hand, to configure the Azure service endpoint, you can refer to this blog: Automating Azure Resource Group deployment using a Service Principal in Visual Studio Online: Build/Release Management.

Resources