Azure Devops Pipeline Deployment to IIS

Like Tweet Pin it Share Share Email

Azure Devops Pipeline Deployment of .NET Web App and SQL Server database to IIS:

  1. Login to Azure Devops at: https://dev.azure.com
  2. Click on Pipelines on the lefthand column
  3. Click on New pipeline on the top right corner:

  4. Your screen would then look like this:

  5. Click ‘Use the classic editor
  6. Select the Repo and Branch from Azure Repos (or GitHub in this case) and click Continue:

  7. Select the ASP.NET template and click Apply:

  8. Your pipeline for building the application is almost complete:

  1. Next, click Save & queue at the top, then Save & run:

  1. Wait a few minutes for the build pipeline to start and finish. There should be a success message at the bottom of the screen:

  2. A drop folder should be created within the Artifacts section:

  3. For this application, we have a database that we need to deploy. (Skip this step if you don’t have a database.) We need to copy the DACPAC(SQL Server Database backup) file to the artifacts directory, as you can see it’s missing above. The release pipeline that is created later needs the DACPAC file to deploy to SQL Server. So, in the build pipeline, click the ‘+’ sign to add a task and select ‘Copy files’ and click Add:

  4. In the Copy Files task, rename it to ‘DACPAC’ or something to make it clear what the task does. Then, set the Source Folder to the ‘db’ directory (in this case that’s where the DACPAC file is stored), and set Contents field to ‘**’, and the Target Folder to ‘$(build.artifactstagingdirectory)’ as that will allow the Release Pipeline to find the DACPAC file:

  5. When you run the build pipeline again, it should have the DACPAC file in the drop directory:

  6. Next, we need to create a deployment Group or Groups (if you want to separate your deployments to multiple servers in the future). In this case, I’ve kept it simple to just have one deployment group to handle one connection to a Windows Server which contains both IIS and SQL Servers. Under the Deployment Groups menu, create a new deployment group. You should see something like this after setting the name:

  7. Copy the Powershell script to the clipboard along with the token:

  8. Next, open a powershell Window as an administrator, and paste the script into the window, and press enter to run. Follow the directions as required:

    You now have a deployment group setup, with an Azure agent running on your server! This will allow the actual deployment of your application and Database to the server to happen.

  9. Next is the creation of a Release Pipeline. First, click Releases on the left menu, then New release pipeline:

  10. A basic release pipeline is created for you:

  11. Select the IIS Website deployment template and click Apply :

  12. Click on Add an artifact:

  13. Select the build pipeline that you created previously and click Add:

  14. Click on the Stage 1 tasks link to see your newly created release pipeline:

  15. On the Stage 1 bar, click Unlink all, as you’ll need to manually set all options.
  16. Next, click on the IIS Deployment bar, and Enter the correct Deployment group. Also, in the Required tags field, enter any tags you may have entered when setting up your Deployment Group (or you can enter none if you only have one server to deploy to):

  17. Click on IIS Web App Manage and enter the Website name and Physical path. Make sure to enter something different than the Default Web site:

  18. Click on IIS Web App Deploy and enter the same Website name and the correct .zip file name:

  19. Next, Click on Deploy using: dacpac. Make sure to select the correct DACPAC file from the drop directory and set the Server Name, Database Name and Authentication to these values shown:

  20. Click Save, then Create release, Create again, Click on the Release link to watch the release being deployed to IIS!:

  21. When you see the success message, it has been successfully deployed to IIS AND SQL Server!
  22. Test your application to ensure it’s working. Here is what you should see if you’ve successfully deployed the demo application from my public github Repo:

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *