How to deploy an ASP.Net docker containerized application to an On-Premise Server, using Azure CI-CD Pipelines? - docker-compose

I have a multi-layer Asp.Net Application running. Due to it's multi-layer nature, I have to build a container for it and deploy it as a container.
Is there anyway I can deploy it to an existing server using Azure-Pipelines?
All other support that I am finding online is related to deploying to Azure App Services, however I would like to deploy to an existing production environment.

Is there anyway I can deploy it to an existing server using Azure-Pipelines?
Since you are deploying to the local environment, you can use Self-hosted Agent(Build Pipeline and Release Pipeline) or Deployment Group(Release Pipeline).
Then you could try the following pipeline settings.
Here is a blog about ASP.Net Application Deployment in Docker for Windows.
You could use Command Line Task to run the docker command. In this case, you can move the local build and deploy process to azure devops
By the way, if you have the Container registry Service connection in Azure Devops, you could use the Docker task or Docker Compose task.

Related

Can we deploy application to multiple Vms on multiple clouds with Github Actions?

I have an application which I want to deploy to a number of VMS on Azure and AWS, I was working with Azure DevOps before and it provided very nice features to achieve this with deployment groups etc. Now I want to work with Github and I am really having problems to design my CI CD pipeline since Github actions do not have any feature which could be used to do deployment on a set of VMS. If there are please guys share your thoughts any article would be appreciated. Thanks
You can firstly consider to deploy application to one Virtual Machine with Github Actions.
Just in the environment of Azure, all you need is to use GitHub Action to build a virtual machine (VM) within Azure.
you can learn the detailed steps to deploy application to one Virtual Machine with Github Actions in:How to use GitHub Actions to deploy an Azure Virtual Machine.
For multi-environment deployments either in Azure or AWS with GitHub Actions, I recommend you to use Octopus Deploy as a reference. you can still refer to Multi-environment deployments with GitHub Actions and Octopus to deploy Virtual Machine on AWS.
For
deploy application to multiple Vms
We recommend you to use Azure Batch to run parallel workloads. It can allow you to deploy application to multiple Vms at one time in batch in the basic of deploy application to one Virtual Machine.
You can run the batch job using Azure CLI by following the example: Run Batch job with the Azure CLI.

how to deploy an application to a particular ubuntu server using azure-devops?

I have my code in the azure repos.I have created the release pipeline which runs the task "npm install" and "npm run start".This will deploy my application.But I want to deploy this application to my ubuntu server 206.189.22.155 from the azure release pipeline.Is there any way I can configure the release pipeline to use my ubuntu server?
The only agent pool available for me is "Azure Pipelines" and for agent specification I used "ubuntu-16.04".Iam totally confused about how this works.
I just want my application to run on http://206.189.22.155:5000. I can run the application directly in the server, but the whole point is to run it from the release pipeline.So how do I connect the pipeline to my ubuntu server?I think my default azure uses some kind of virtual machine for deployment.
You can create a deployment group in Azure DevOps. Deployment groups in Azure pipelines make it easier to organize the servers you want to use to host your app. In Azure pipelines -> Devployment group, select “+New” button and type of target to register. Copy and run the Registration script in your Ubuntu server.
You can refer to https://learn.microsoft.com/en-us/azure/devops/pipelines/apps/cd/deploy-linuxvm-deploygroups?view=azure-devops&tabs=java-script#define-your-ci-build-pipeline and https://learn.microsoft.com/en-us/azure/devops/pipelines/release/deployment-groups/index?view=azure-devops for more detailed information
After you create the deployment group, you can choose it in your release pipeline
And after you configure you deployment group, you can deploy your app to the specific server.

Azure App Service Deploy Release (Azure DevOps) overwrites the Multi-Container Docker Compose (Preview) settings in Azure Portal

I have a multi-container app running with App Service - Web App for Containers. It all works fine as long as the Docker Compose (Preview) configuration is provided under the Container Settings tab.
Currently, I am using Azure DevOps to create builds for specific containers, and then use the Continous Deployment option (in Azure Portal) under Container Settings to pull the latest deployed container image from ACR. This also works fine. I can run builds for individual containers, and deploy only specific container without affecting the web app. (Each container is a separate project, and only has a Dockerfile without requiring docker-compose)
However, when I create a Release from Azure DevOp using Azure App Service Deploy (version 4.*), the Docker Compose (Preview) configuration in Azure Portal is completely wiped out, and it defaults to Single Container and the application breaks. The Docker Compose configuration is needed as it makes the main container aware of the other containers.
I am using version 4.* of Azure App Service Deploy. I would like to use the Release feature of Azure DevOps as it provides more control.
Is there a way I can specify the docker-compose multi-container configuration from Azure App Service Deploy version 4 so that the App Service is aware of the multi-container configuration and not wipe out the multi-container config in Docker Compose (preview)
Thanks,
Karan
Replace the Azure App Service deploy task in your Release pipeline with an Azure Web App for Containers task. There are parameters for multiple images and a configuration file (Docker-Compose.yml).
As Dave mentioned this is possible using the AzureWebAppContainer task, however the documentation does not mention the options regarding multi-container deployment.
I had to dig into the source code of that task to discover the task parameters.
https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/AzureWebAppContainerV1/taskparameters.ts
I'll summarise my setup to give you an idea how it can be used. I have a multi-stage pipeline defined in YAML. There are two stages, the first stage builds and publishes the Docker images and the second stage updates the Web App for Containers app service.
The first stage also produces an artifact, namely the docker-compose.yml file that is used to configure the Web App for Containers app service. In my repository I have a template for this file. During the pipeline execution the tags of the docker images are replaced within this template (e.g. using envsubst or sed). Then the resulting docker-compose.yml file is published as an artifact.
- task: PublishBuildArtifacts#1
displayName: "Publish artifact"
inputs:
pathToPublish: $(Build.SourcesDirectory)/pipelines/assets/docker-compose.yml
artifactName: yml
In the second stage of the pipeline the artifact is downloaded and used to configure the Web App for Containers. In the example below the AzureWebAppContainer is a step of a deployment job.
- task: AzureWebAppContainer#1
displayName: 'Azure Web App for Containers'
inputs:
azureSubscription: '<YOUR_SUBSCRIPTION>'
appName: '<YOUR_WEB_APP_FOR_CONTAINERS>'
multicontainerConfigFile: $(System.ArtifactsDirectory)/yml/docker-compose.yml
The generated docker-compose.yml is stored as an artifact and you can always consult it later.

How do I deploy to an Azure Web App on Linux using Azure DevOps?

The docs have a link to Deployments > Azure Web App on Windows but no link to Azure Web App on Linux.
[Update]
Here is my latest attempt
It is not possible to data enter the app service name.
[Update]
It turns out that the order of filling things in matters.
Once I filled in the settings for the pipeline task then I could enter data in the Azure App Service Task.
The Azure App Service Deploy task supports Web App on Linux app service type, so you can directly deploy Azure Web App on Linux through this task. See Deploy: Azure App Service Deploy for details.
The Azure App Service Deploy task is used to deploy to a range of App
Services on Azure. The task works on cross-platform agents running
Windows, Linux, or Mac.
Reference this similar thread : VSTS Deploy to Azure WebApp For Linux
And you can also reference this article for the deployment: Docker Deployment to Azure App Service (Linux) using VSTS

Automated deployment for Docker images which is in php technology

I am working on an automated Azure build for Docker application.
I need to connect to container registry and pull the images from container and push it to Docker Swarm resource deployed in Azure.
Can you please suggest me the steps.
I need to automate using a PowerShell script