Forum Discussion

Imransh21's avatar
Imransh21
Copper Contributor
Jun 23, 2024
Solved

On Premise DevOps 2022 CI/CD pipeline to Host Application on IIS

Hi All,   We have deployed DevOps 2022 server on our On-Premise server which we upgraded from TFS 2018. I would like to know the steps about Build and Release pipeline which can auto deploy applica...
  • DTB's avatar
    Jun 24, 2024

    Hi Imransh21,

     

    Based on the information you've provided I would approach it in the following way:

    CI/CD Pipeline for IIS Deployment

    Prerequisites

    1. Active Directory Environment: Ensure your servers are part of the Active Directory domain.
    2. DevOps Server 2022: Installed and configured on your on-premise server.
    3. IIS Server: Ensure IIS is installed and configured on your test server.
    4. SQL Server: Ensure your SQL server is up and running.
    5. Development Tools: Ensure developers have Visual Studio 2019/2012 configured.

    Step 1: Configure the Build Agent

    1. Install the Azure Pipelines Agent:

      • Download the agent from your Azure DevOps Server. Go to your Azure DevOps Server, navigate to your project, and select Project settings > Agent pools.
      • Select the default pool (or create a new one), then select New agent.
      • Follow the instructions to download and configure the agent on the server where you want to run builds.
    2. Configure the Agent:

      • Run the downloaded agent package and follow the setup wizard.
      • Ensure the agent is running as a service and connected to the correct project and agent pool.

    Step 2: Create a Build Pipeline

    1. Define the Build Pipeline:

      • Go to your DevOps project and navigate to Pipelines > New pipeline.
      • Select Classic Editor to create a pipeline without YAML.
      • Choose your repository and select Continue.
      • Select the ASP.NET Core template (or a relevant template based on your project).
    2. Configure Build Steps:

      • Restore NuGet Packages: Add a task to restore NuGet packages.
      • Build Solution: Add a task to build your solution. Ensure you specify the correct solution file path.
      • Run Tests: If you have unit tests, add a task to run these tests.
      • Publish Build Artifacts: Add a task to publish build artifacts. Set the path to publish (e.g., $(Build.ArtifactStagingDirectory)).
    3. Save and Queue the Build:

      • Save the build pipeline and run it to ensure it completes successfully.

    Step 3: Create a Release Pipeline

    1. Define the Release Pipeline:

      • Navigate to Releases under Pipelines, then select New pipeline.
      • Choose an empty job template.
    2. Add an Artifact:

      • Link the build pipeline you created as the source for the release.
    3. Define Stages:

      • Add a stage for deployment (e.g., IIS Deployment).
      • In the Tasks tab, add the following tasks:

    Step 4: Deploy to IIS

    1. Copy Files:

      • Add a Copy Files task to copy files from the build artifact to the IIS server.
        • Source Folder: $(System.DefaultWorkingDirectory)/_yourbuildpipeline/build
        • Contents: **
        • Target Folder: \\yourIISServer\c$\inetpub\wwwroot\yourapp
    2. Deploy using IIS Web App Deployment:

      • Add an IIS Web App Deployment task:
        • Package or Folder: $(System.DefaultWorkingDirectory)/_yourbuildpipeline/build
        • Web App Name: Your IIS site name.
        • Remove Additional Files at Destination: Checked.

    Step 5: Configure IIS and SQL Server

    1. IIS Configuration:

      • Ensure the application pool and site are configured in IIS.
      • Set appropriate permissions for the deployment account.
    2. SQL Server Configuration:

      • Ensure connection strings in your application configuration point to the correct SQL Server instance.
      • Verify that the database is accessible from the IIS server.

    Step 6: Automate the Process

    1. Continuous Integration:
      • Set up triggers in the build pipeline to trigger a build on every code check-in.
    2. Continuous Deployment:
      • Set up triggers in the release pipeline to deploy automatically after a successful build.

    Step 7: Test and Monitor

    1. Test Deployment:

      • Test the deployment to ensure the application is correctly deployed and running on the IIS server.
    2. Monitor:

      • Use Azure Monitor or other monitoring tools to keep track of build and deployment processes.

     

    I hope this will help you with your pipeline

    Best regards,

    Daniel 

     

Resources