deploy app to on-prem environments with azure dev ops - azure-devops

I'm building an Azure DevOps pipeline to deploy a custom-build powershell application to several on-prem environments that we support. I configured the required agent pools and installed them as a service on the on-prem environment.
Next, I have set up my pipeline in Azure DevOps, selecting a GitRepo:
Build (with the steps: Use Nuget, Nuget Restore, Build solution, Update version, Copy Files, and Publish build Artifact)
Release (with step: Publish Build Artifact)
Some things are unclear for me:
Do I need the Publish Build Artifacts twice? Can the Build pipeline
end with Copy Files step, and that the Release pipeline picks up this
artifact?
It is my understanding that the release publishes the app to the
on-prem environment (in my case). Where can I set a custom path (ie:
C:\deployed_apps) where the app needs to be deployed? When I tested
this pipeline, I got errors that the path I created using an variable
was not found.
What am I missing in my setup to get this pipeline working?

As #Shayki Abramczyk
pointed out this task is not for deployment, it just upload your Build Artifacts to azure devops server where your release pipeline can download directly.
In your case, if you want deploy your application to several on-prem environments, You need to create a deployment group first, A deployment group is a logical set of deployment target machines that have agents installed on each one. You application will be deployed to those machines in a deployment group in release pipeline. Check here for more details about deployment group.
After the deployment group is created, you can add a deployment group job by click the 3 dots, and then specify your deployment group as below pic shows, You can then simply add a copy file task or other deployment tasks to deploy your application to your on-prem machine.

In the release pipeline you shouldn't use the Publish Build Artifact. in the end of the build you put this step, what this step does? upload your artifacts to the Azure DevOps or to a file share. now in the release pipeline you choose the build artifact (in the left pane). the first thing that the agent does when the release pipeline started is to download the build artifacts to the agent. now you need to take them and deploy it to your environments. how? it depends which kind of application is (it can be just copy files, it can be deploy to IIS, etc.).
You can put the path in the variables tab and use this variable when you deploy the app (with copy files task, for example).

Related

How to build a dashboard for YAML Pipelines with deployment job

We have been converting our Release pipelines in Azure DevOps to instead be YAML files that run as Pipelines. This is so we can store our deployment process as code. The deployment process is working well - so a developer commits code and the Pipeline builds and publishes the artifact in one stage and then it auto-deploys to the QA environment in another stage. Subsequent stages deploy to an Environment (e.g. QA, Staging, Production) each of which requires some approval(s). The deployments themselves aren't the issue.
What I'm struggling with is unlike the old Releases there isn't a dashboard that will tell me which version of the project is in each environment. The Pipeline summary represents each stage for the Run as a dot (running, succeeded, failed, canceled, etc.) but wasn't built to represent what each environment has (probably because a stage doesn't have to be a deployment).
Is there somewhere else I can look for this information or do I have to build my own dashboard by calling the AzDO APIs? Looking at the Environment gives a list and I can root through the history, but that's not the experience our developers are looking for.

Azure DevOps link release pipeline to deployment group

I am working with a self-hosted agent to release code into a target on-prem server. In my case, I just want to copy a file from the artifacts directory (.exe file) into a folder on my machine. So I created a deployment group and installed the on-prem agent on this server. I created the release pipeline...but since I am just copying a file, I couldn't use one of the predefined templates. So I started with Empty Job. Then I added a step to copy the file using the "Copy Files" step. However, no where in this process is there a place to associate a deployment group. Some of the pre-defined templates have the option to specify the deployment group. But in an empty job with an added step, how do I specify the deployment group? Any ideas?
I was able to add a Deployment Group Job in the Tasks section of the pipeline. Originally I was using the default Task which was running on a Microsoft agent. So was able to delete that one and add a Deployment Group job.

Deploy .NET Core Console App to Windows VM using Azure DevOps

We have a .NET Core Console App which we publish to an On Prem VM using publish feature in Visual Studio. Here is how we configure publishing to a file system.
Target location in the image is actually the folder structure of where we want our app to reside on the VM.
How can we configure the same in DevOps. I can't seem to find any good resource on this.
I have created a CI build pipeline.
You can follow below steps to deploy Console App to the On Prem VM.
1, Create a deployment agent on On-Prem VM. create a deployment group from azure devops portal. Follow the first part of this tutorial to create deployment group. Check the official document for more information about deployment group.
2, Create a release pipeline. See document here.
Setup the artifacts(you should have the publish build artifacts task in the CI build pipeline to publish the console app build artifacts to azure devops server.), and add stage for the release pipeline.
Add a deployment group job in the release stage.
see below screenshot to select the deployment group created in the first step, which contains the deployment agent on the ON-premise VM,
Add copy file task to copy the console app build artifacts to the folder on the ON-premise VM
Another workaround is to use self-hosted agent(steps are similar to above using deployment group). Check the detailed steps in this example.
Hope above helps!

Deploying Multiple WebJobs from the Same Project in a Azure DevOps Release Definition?

So the way that we've structured our code is that we've got several projects in our solution that each have multiple webjobs. We've configured a manual way of releasing these multiple webjobs using the run.cmd files and copying over the pertinent run.cmd file to the root folder depending on which webjob we're trying to release.
I'm wondering if there is any way to do this via a build/release definition in Azure DevOps without having to tear apart the multiple webjobs into individual projects. These multiple webjobs also all live in the same App Service.
What you have done is the simplest way at present, you could just clone the process in Azure DevOps Build/Release Pipeline. There is not any way to do this in Azure DevOps without having to tear apart the multiple webjobs into individual projects.
We've configured a manual way of releasing these multiple webjobs
using the run.cmd files and copying over the pertinent run.cmd file to
the root folder depending on which webjob we're trying to release.
For example, in your build solution step define (add some copy file step to copy necessary files) :-
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)
Create a release definition for this build definition and add a task
Azure App Service Deploy
Select your Azure Subscription and App Service name;
Select your Package or Folder:
$(System.DefaultWorkingDirectory)**\WebJob1.zip
You can similary create another Azure App Service Deploy task for WebJob2.zip and deploy as many webjobs you want through a single build and release pipeline.

Azure DevOps SetUp - Mulitple Project / WebJobs under Single Solution

We have about multiple Projects in a single Solution.
2 projects needs to be deployed as Azure Web App
10 projects are web jobs which needs be deployed to one of the Azure web app
Can someone guide me on how to setup the deployment pipeline for Continuous Integration.
This is one option:
Setup build pipeline so that build will produce ready to install packages. An easy way to achieve this is to use Build solution Task and add following parameters into MSBuild arguments:
/p:TransformConfigFiles=true /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:OutDir="$(build.stagingDirectory)"
(+ of course you need publish symbols path and publish artifact task which are created by default)
Now when you build your solution you should have ready to install packages (zip files).
Next we need to setup deployment pipeline. Here you should use Azure App Service Deploy task. All the other parameters except package or folder should be easy to setup if you have linked Azure subscription into Azure DevOps.In package or folder you can put: $(System.DefaultWorkingDirectory)/**/(name of the zip package you want to deploy).zip.
Web jobs don't differ from apps much, so you should be able to setup their pipelines also with above guide.
For more information about web job deployment check this Microsoft example:
https://blogs.msdn.microsoft.com/tfssetup/2016/05/18/deploying-and-schedule-azure-webjobs-from-vsts-to-azure-web-app-with-bonus-cron-scheduling/