Azure Pipelines Installation

This guide will explain how to deploy from scratch a web App with the Hdiv Agent using Azure pipelines.

Setting up an App Service

If you already have an App service for deploying, you can use that one instead of creating a new one, so you can just go to section "Setting up a project".

Both Linux and Windows based App Services are supported.

1) Log in into and click on the icon "App Services".


2) Click on "Add".


3) Set the proper values for your service. When finished, click "Create".



4) Your service will be deployed


Setting up a project

Some steps can be skipped if you already have an Azure project and repository containing your Web App code. If you already have one, you can jump to step 5)

1) Login into

2) Click the "New project button"


3) Add a project name and description.

4) Go to the "Repos" section of the project to get the options available to add some code. In this page, you can import an existing repository or use the provided options to create a new one.


5) If you do not have a .yml file for deploying your App with Azure Pipelines, you need to add one into your repository. You can use this template to create a file named "azure-pipelines.yml":

# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:

- main

  vmImage: 'windows-latest'

  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  agentVersion: '' #Agent version that is going to be used
  projectDirectory: '.' #path to one project in your solution
  webAppName: 'your-app-name' #your app service name
  consoleURL: 'http://console-host:8089/hdiv-console-services' #Console address. Set to empty if you do not want to use the console
  consoleToken: 'token-value' #console token provided by Hdiv
  enableToolbar: 'false' #Set value to 'true' to enable the toolbar 
  serverName: 'serverName' #Select a name for your server
  isLinux: 'false' #Set to true if you app service runs under Linux

- task: CmdLine@2
    script: dotnet nuget add source --name nexus --username $(nexusUsername) --password $(nexusPassword) --store-password-in-clear-text | dotnet add package Hdiv.AST.Profiler --version $(agentVersion)
    workingDirectory: '$(projectDirectory)'

- task: VSBuild@1
  condition: eq(lower(variables.isLinux),'false')
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: DotNetCoreCLI@2
  condition: eq(lower(variables.isLinux),'true')
    command: 'build'
    projects: '$(solution)'
    arguments: '--configuration $(buildConfiguration)'

- task: DotNetCoreCLI@2
  condition: eq(lower(variables.isLinux),'true')
    command: 'publish'
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory) -r linux-x64'
    publishWebProjects: true
    zipAfterPublish: True

- task: AzureRmWebAppDeployment@4
  condition: eq(lower(variables.isLinux),'false')
    ConnectionType: 'AzureRM'
    azureSubscription: '$(azureSubscription)'
    appType: 'webApp'
    WebAppName: '$(webAppName)'
    AppSettings: -HDIV_TOOLBAR_ENABLED $(enableToolbar) -COR_ENABLE_PROFILING 1 -COR_PROFILER {1adbf8d7-8774-4733-aa10-4376ba3bd37a} -COR_PROFILER_PATH_32 D:\Home\site\wwwroot\hdivsecurity\agent\x86\Hdiv.AST.Clr.Profiler.dll -COR_PROFILER_PATH_64 D:\Home\site\wwwroot\hdivsecurity\agent\x64\Hdiv.AST.Clr.Profiler.dll -CORECLR_ENABLE_PROFILING 1 -CORECLR_PROFILER {1adbf8d7-8774-4733-aa10-4376ba3bd37a} -CORECLR_PROFILER_PATH_32 D:\Home\site\wwwroot\hdivsecurity\agent\x86\Hdiv.AST.Clr.Profiler.dll -CORECLR_PROFILER_PATH_64 D:\Home\site\wwwroot\hdivsecurity\agent\x64\Hdiv.AST.Clr.Profiler.dll -HDIV_AGENT_HOME D:\Home\site\wwwroot\hdivsecurity\agent -HDIV.NET.AST.BRIDGE.ENABLED=true -HDIV_AGENT_PROFILER_PLATFORM 327680 -HDIV_LICENSE_DATA $(licenseData) -HDIV_CONSOLE_URL $(consoleURL) -HDIV_CONSOLE_TOKEN $(consoleToken) -HDIV_SERVER_NAME $(serverName)
    packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'

- task: AzureWebApp@1
  condition: eq(lower(variables.isLinux),'true')
    azureSubscription: '$(azureSubscription)'
    appType: 'webAppLinux'
    appName: '$(webAppName)'
    AppSettings: -HDIV_TOOLBAR_ENABLED $(enableToolbar) -CORECLR_ENABLE_PROFILING 1 -CORECLR_PROFILER {1adbf8d7-8774-4733-aa10-4376ba3bd37a} -CORECLR_PROFILER_PATH_64 /home/site/wwwroot/hdivsecurity/agent/x64/ -HDIV_AGENT_HOME /home/site/wwwroot/hdivsecurity/agent -HDIV_AGENT_PROFILER_PLATFORM 327680 -HDIV_LICENSE_DATA $(licenseData) -HDIV_CONSOLE_URL $(consoleURL) -HDIV_CONSOLE_TOKEN $(consoleToken) -HDIV_SERVER_NAME $(serverName)
    package: '$(Build.ArtifactStagingDirectory)/**/*.zip'

In the variables section, in the variable "webAppName", the proper name of the App Service should be set.

Also, in the variable "agentVersion", the Agent version that will be used must be set.

The variable "projectDirectory" must contain the path of a valid project file (.csproj) of your solution.

The variable "enableToolbar" indicates if the toolbar should be shown.

The variable "consoleURL" is used to store the address of the console. This field can be left empty if no console is going to be used.

The variable "consoleToken" contains the token of the console provided by Hdiv.

The variable "serverName" contains the name of your server. Use a name that identifies the server where the agent is installed. This name will be shown in the console.

The variable "isLinux" indicates if your web App runs under a Linux environment. If false, it is assumed that your web App runs under a Windows environment.

If you already had a .yml file for deploying with azure pipelines, you will need to merge your file with this one, merging/adding into your file the needed tasks. The task "CmdLine@2" adds the Hdiv nuget package into one of you projects and must be run before building the App. The tasks "AzureWebApp" (Linux) and "AzureRmWebAppDeployment@4" (Windows) deploy the App and must contain the input "AppSettings" that sets the environment variables that the Agent needs for running.

Set the pipeline variables

1) In go Pipelines, select your pipeline and edit it.


2) Click on Variables


3) Add the required variables


Some variables need to be set:

  • azureSuscription: This variable contains your Azure subscription name and ID.

  • licenseData: The license data provided by Hdiv.

  • nexusPassword: The Nexus password for Hdiv NuGet repository provided by Hdiv.

  • nexusUsername: The Nexus user name for Hdiv NuGet repository provided by Hdiv.


Run the pipeline

1) In go to "Pipelines", select your pipeline and click on "Run".


2) In the next screen, click on "Run".


3) A new job should have been created to deploy the App.


4) You can click on the job and see how the deployment process is going. After some minutes, the tasks of the job should contain a green mark.


5) Make sure that your Web App is running


6) Now, you can navigate to your deployed app and check that everything is ok. The url of the page would be the one that was defined in your App service.