Thursday, July 7, 2022

Azure Pipeline to setup Dotnet core application to IIS server using Azure DevOPS

Description: Here I have explained, How to setup .net core application from github source code repository to Microsoft IIS server through Azure DevOPS using Deployment Group.

Setup:

  • IIS server 
  • .net core hosting bundle [install 6.0 for this post] download link
IIS






















Dotnet Core 6.0 Hosting Bundle























Setup Deployment Group:

















After setup both the things on IIS server, Now need to setup deployment group from Azure DevOPS. In Azure DevOps select the Organization and navigate to Pipeline --> Deployment Group --> Availability Pools --> Add new


Give Name to Target group and select windows [Type of registrar]. Copy the command by click on copy script to clipboard 























Run copied command to IIS server in Power shell by Run as administrator






















As mentioned in the above figure, while registering the agent it will prompt for several requirements.


Enter Authentication Type [PAT]   
PAT [Personal Access Token need to generate from the User setting and click on PAT





















Create new token and select Deployment groups in permission tab as follow and save the token. Also keep the token to notepad for reference 





































Enter replace →y
Group tags → y
Add tags → dev, prod (to specify the scope the deployment group will be handling we using tags)
Add credentials we used while creating the vm as we are logged in to the vm through that account.























After run above command if connection established successfully, then you can get status (Online)



















Setup Build Pipeline: 

To setup build pipeline using github repository, open Azure devops and navigate to Pipeline and create new pipeline 

















Select Github and source code and  use repository for dotnet core [https://github.com/harpal1990/VSCoreNew.git]

Once you select repository, according to source code it ask to select framework where you want to deploy the application. So in our case, I am selecting ASP.Net Core (.Net Framework)

Once you select repository, it will automatically create azure-pipelines.yml file. To publish the artifact need to add stage for same and add it to yml file then click on save and run























Once Pipeline created click on save and run, it will create artifact of the source code. After it navigate to Release pipeline and click on new pipeline 


















Create Empty Job and give name to it. First add artifact created from the build pipeline and click on continuous deployment trigger to enable it.























After add the artifact, Add task --> Add deployment group Job --> fill all the require details and add deployment group























After adding deployment group, click on + sign and add IIS web app deploy and IIS web app manage both the tasks.
















After add both the task configure both of them one by one. 

First click on IIS Web app deploy and fill the require details like Website Name. Also ticked on Take App Offline























Now click on Manage IIS Website step and give Website name [For this example I have used Default Web Site]
























After fill all the details save the pipeline and click on create release. Once release created the pipeline executed automatically and if not face any error then it show release run successfully message





















Before executing the pipeline web server on default site:





















After executing pipeline web server default page





No comments:

Post a Comment