To make a smoother setup experience in Azure DevOps, XLENT Link has provided templates for continuous integration and deploy in the repository nexus-azure-devops-tools. We will refer to it below when we use it's pipeline templates.
Setup connections
- Go into your
PoCproject in Azure Devops. - Go to
Project settings - Go to
Pipeline->Service connections
GitHub connection
Create a new service connection to GitHub named github-nla-acme-nexus (We will grant it from the user nla-acme, therefore we add nla to the name)
- Allow all pipelines to use this connection.
- Grant access for Azure Pipelines to access your GitHub organization
- Select the
BusinessApi.Librariesrepository. - Approve and install Azure Pipelines for the
BusinessApi.Librariesanddeveloper-toolsrepository - Go into
Policiesand allow all pipelines to use this connection.
Azure connection
Create a new service connection to Azure Classicnamed azure-acme-nexus
- Select
Certificate Based - Click on
publish settings file - Select your subscription, validate
- Download
- Use the file to fill in the form, verify connection
Create a new service connection to Azure Resource Managernamed azure-acme-nexus
- Select your subscription and resource group
- If they don't appear, try this:
- Use full version (bottom of form)
- Add the subscription id and name
- Go back to the automated version
- Select the
pocresource group - If it fails; close and try again
- Click on
publish settings file - Select your subscription, validate
- Download
- Use the file to fill in the form, verify connection
NuGet feed
When you want to download the NuGets you need the URL of the NuGet Feed and when you want to push NuGets to the feed you need the Feed name.
- Go to your azure devops project, typically https://dev.azure.com/AcmeNexus/PoC
- Go to
Artifacts - Note the name of the feed that you want to use, this is the feed name to use later. Typically
AcmeNexus - Select the feed
- Go into
Connect to feed - Select the
Package source URL, this is the URL you will use later
Business API
- Create a new Build pipeline
- Code:
GitHub - Select the
BusinessApirepository - Grant access for Azure Pipelines to access the repository
- Use
ASP.NET Corefor configuration. NOTASP.NET Core (.NET Framework) - Copy the yml text below into the
azure-pipelines.yml - Run (don't worry if it fails)
- Go into the repo
- Move the
azure-pipelines.ymlfile into the business api project folder. - Commit and push
- Edit the pipeline
- Go into Trigger settings
- Change the name to
BusinessApi - Go into YML settings
- Change the yml file location to where you moved the
ymlfile. - Save and queue (this time it should not fail)
resources:
repositories:
- repository: azure-devops-tools
type: github
endpoint: 'github-nla-acme-nexus'
name: 'nexus-link/nexus-azure-devops-tools'
ref: 'refs/heads/master'
trigger:
branches:
include:
- master
paths:
include:
- 'src/Acme.BusinessApi.Service/*'
jobs:
- template: 'templates/netcore/v1/jobs/webapp.yml@azure-devops-tools'
parameters:
testProjectsPath: ''
appProjectsPath: '**/src/Acme.BusinessApi.Service/**/*.csproj'
buildConfiguration: 'Debug'
azureSubscription: 'azure-acme-nexus'
webAppName: 'poc-business-api-acme-nexus'
appSettings: '-ClientId $(ClientId) -ClientSecret $(ClientSecret) -Stackify.Key $(Stackify.Key)'
Nugets CI/CD
Give Azure DevOps access to your GitHub repository.
Time to make build pipelines for all your nuget packages. First we make one template that we can reuse.
- Create a new Build pipeline.
- The code is on GitHub
- Select the
BusinessApirepo - If asked for: Use
ASP.NET Corefor configuration. - Copy the yml text below into the
azure-pipelines.yml(changeacmeto your organization name) - Run (don't worry if it fails)
- Go into the repo
- Move the newly created yml file into the
src/Acme.BusinessApi.Libraries.Contractsfolder. - Commit and push
- Edit the pipeline
- Go into Trigger settings
- Change the name to
BusinessApi.Libraries.Contracts - Go into YML settings
- Change the yml file location to where you moved the
ymlfile. - Save and queue (this time it should not fail)
- Done. Now we can clone this and use it for the other NuGets.
resources:
repositories:
- repository: azure-devops-tools
type: github
endpoint: 'github-nla-acme-nexus'
name: 'nexus-link/nexus-azure-devops-tools'
ref: 'refs/heads/master'
trigger:
branches:
include:
- master
paths:
include:
- 'src/Acme.BusinessApi.Libraries.Contracts/*'
jobs:
- template: 'templates/netcore/v1/jobs/nuget.yml@azure-devops-tools'
parameters:
nugetProjectsPath: 'src/Acme.BusinessApi.Libraries.Contracts/*.csproj'
testProjectsPath: 'test/Contracts.Test/*.csproj'
publishVstsFeed: '{your feed name}'
Clone for the other Nugets (Controllers and Sdk):
- Go to the
BusinessApirepo. - Copy the yml file from the Contracts library to the next nuget folder and update the yml file with the correct paths.
- Go to the
BusinessApi.Libraries.ContractsBuild pipeline - Clone it
- Rename it
- Update the YAML file path
- Save and queue, Save and run
Azure Function apps CI/CD
- Create a new Build pipeline
- Code:
GitHub - Select the
Nexus.FunctionAppsrepository - Grant access for Azure Pipelines to access the repository
- If asked for: Use
ASP.NET Corefor configuration. - Copy the yml text below into the
azure-pipelines.yml - Run (don't worry if it fails)
- Edit the pipeline
- Go into Triggers
- Click on YAML
- Change the name to
Nexus.FunctionApps - Save and queue (this time it should not fail)
resources:
repositories:
- repository: azure-devops-tools
type: github
endpoint: 'github-nla-acme-nexus'
name: 'nexus-link/nexus-azure-devops-tools'
ref: 'refs/heads/master'
trigger:
branches:
include:
- master
jobs:
- template: 'templates/netcore/v1/jobs/functionapp.yml@azure-devops-tools'
parameters:
appProjectsPath: 'Nexus.Functions/*.csproj'
testProjectsPath: ''
azureSubscription: 'azure-acme-nexus'
webAppName: 'poc-function-app-acme-nexus'
appSettings: '-Stackify.ApiKey $(Stackify.ApiKey) -AsyncCallerApp.PostUrl $(AsyncCallerApp.PostUrl) -Authentication.ClientId $(Authentication.ClientId) -Authentication.ClientSecret $(Authentication.ClientSecret) -Authentication.Url $(Authentication.Url)'