Skip to main content

Deploying asp.net core application on docker using Microsoft Azure Infrastructure Part - 1

There are several ways to deploy the Linux based asp.net core application in azure infrastructure,

In this series we are exploring the Microsoft Azure Web App - (Linux Infrastructure) option to deploy our asp.net core application.

If you are new to docker or very basic theoretical knowledge of the docker based container deployment, than it's right choice for you to deploy application on Microsoft Azure Web App in Linux Infrastructure cause most of the docker based tasks are handle by the Microsoft Azure like create, build & run image for docker. We don't even write single docker based configuration on our ASP.NET core project.

Now let's create the our first application using ASP.NET Core 1.1 SDK, and run locally to verify it's running correctly or not. If everything is okay than we going to publish application using below command

RUN dotnet publish -c Release -o PublishOutput

or Visual studio folder approach.

2

Currently Microsoft Azure App Service doesn't support the Web App Deployment for Linux Environment so we have to publish using traditional File System or FTP approach.

We have our published artifacts on local machine which we need to deploy on Microsoft Azure Web App Linux machine, in order to do that we need to create Web App on Azure portal.

3

Now our Linux machine are ready on azure to host our first asp.net core application. Sadly, we do not take remote desktop connection to copy the files from our local system to Azure Web App machine. so, we can upload published artifacts via FTP. If you don't setup the the FTP User in your Azure account please do it now by clicking on this link.

Azure create root user named "site" in Linux machine and under the wwwroot folder. which we need to put these published artifact from local machine to Linux server by connecting via FTP client.

Next step to tell web app to start docker container under the Settings -> Docker Container

4

5

By passing the below argument in Startup File Parameters, here Meetup.Web.dll is main Web or API project dll name and it's case sensitive.

dotnet /home/site/wwwroot/Meetup.Web.dll

Start Web app and browse the application which run on docker container in Linux machine

6

Summarize the above steps what we have done,

  1. Build application
  2. Run test against application
  3. Publish application
  4. Create artifacts
  5. Connect FTP
  6. Upload via FTP
  7. Restart Web App

this is deployment life cycle and developer doing over and over again when new application need to publish, let's automate this process via Visual Studio Online Service

First thing first, we need to create Build Definition on Visual Studio in order to Build & Publish artifact

Build, run test, publish application & Create artifacts

Select ASP.NET Core template when creating the new build definition in visual studio team service,

7.png

default template comes with below process,

8

which generate build after every checked-in done in repository.

Connect, upload via FTP & Restart Web App

After successfully generate build we need to create release definition under the Release tab in VSTS.

9

Clicking on the 1 phase, 4 tasks link, we have 4 tasks let's go one by one

  1. Stop Web App
    • Add Azure App Service manage task from List10
    • Under the Action dropdown menu select Stop App Service11
  2. Extract Files
    • Generated artifacts are in zip file format, so we need to extract in destination folder. Here we create Published folder under the build directory and set the path in Destination folder12
  3. FTP Upload
    • After unzip the publish files we need to push those files in Linux machine13
  4. Start Web App
    • And after successfully upload files, we need to start again web app14

We just deployed our ASP.NET core application on Web App Linux docker container with CI/CD. Only drawback of Web App Linux machine is currently support 1.0 & 1.1 .NET Core Framework.

Comments