- Set up an Azure DevOps organization and create new project: If you don't already have an Azure DevOps organization that you can use for this project or use an existing organization and new project
- Git for Windows
- Visual Studio Code
- Install Terraform
- make a new directory and cd into it use the command below to generate a sample dotnet template
dotnet new webapp
Link to repo: https://github.com/RussMaxwell/PythonWebApp
-
Create a microsoft account
-
Create a new AzureDevops account
-
create an organisation
-
copy the push an existing repository from command line
- on the termnal initialize the repo
git init
Then stage all the changes by using:
git add .
commit those changes:
git commit -m "commit message"
- now paste the previously copied code from the project repo to the Terminal
- it should bring a git credential page login, input your details
- refresh the web browser, you should see the files
-
we can actualy define the permission in the custom option but for this project we will go with full access
-
Vist https://sonarcloud.io/signin and sigin in with your Azure devops account
-
import the project you want by filling up the below:
-
We are to fill the name of our oganisation and the previously copied PAT and proceed to next page
-
Now we set it up, pick the Azure pool and Agent specification you want the code to run there's Mac,Linux and Windows with various Specifications. I am using Windows Latest
-
here i define the parameter where it should restore and build
csporj
-
Here we will be add the token given from sonarcloud.io here and give our connection on a name
-
We'll set the Prepare analysis on the cloud job and fill the highlited boxes with the data given from the sonarcloud.io
Incase your build fails try rearrangeing the agent order like this :
-
Our build is succesful now let's return to sonarcloud.io and refresh
-
Steps to take to setup Build validation
- We going to set up pull request in the sonar cloud setting Administration > General settings > Pull request
we are gonna see the pull request scan in out sonarcloud
Task 4 - Integrate Mend (Formerly White-source) for code quality and vulnerabilities issues with your code.
-
We go to the Market place and install MEND formerly know as white source bolt
-
Select the free version and install inside your organisation
**Task 5 Create a basic build pipeline from a template and set the trigger settings to invoke a continuous integration build and verify the build completed successfully along with the code quality result from sonar-cloud and mend-bolt **
- From the previous task we have built a dotnet pipeline an have intergrated sonarcloud and Mend bolt.
Now to set a trigger to invole a continuous intergration build
-
after a successful build let's check out Mend bolt and sonarcloud
I'll be installing terraform using chocolatey from my terminal
-
go to the official chocolatey website
-
using the powershell with administrative access paste:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
- after chocolatey is installed use te below command to install Terraform on windows
To install it
choco install terraform
To update it
choco upgrade terraform
To uninstall it
choco uninstall terraform
Set the Terraform Backends and Provider and Provision :
- An Azure App Service Plan and an Azure App Service
- An Azure App Service for container,
- Azure Container Registry,
- Azure Container instance
- Azure Kubernetes Service
refrence: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
-
After setting up the main.tf and variable.tf
-
run a
terraform build
if there is no error -
run a
terraform apply
-
type yes
refrence: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service
-
After setting up the main.tf and variable.tf
-
run a
terraform plan
if there is no error -
run a
terraform apply
refrence: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_app
-
run a
terraform apply
refrence: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_registry
-
run a
terraform apply
-
From our previoulsy created repo, let's add a text in the index.cshtml file:
-
Go to pipeline and classic editor
--configuration $(BuildConfiguration) --output
$(Build.ArtifactStagingDirectory)
After a succesful Dev environment deployment
Set a pre-deployment approval in the QA stage.
-
upgrade the spec to an higher service plan, after the project enusre to terminate all provisoned resources to avoid billings
-
go to the repo and make a new commit in the index.cshtml file
-
go to azureportal, to the production app service and under deployment slot, click swap
- Navigate to Organization Settings > Security > Policies, and turn on the Third-party application access via OAuth
-
open a slack account and sign in using the app or your web browser
-
create a new workspace or use an existing one, i'm creating a new one
-
go to the settings and add azure pipelines to any channel of choice using these steps:
- connect and specify what results you want to see build pipelines or release pipelines and can even specify the exvcat build form the numerous ones you have
/azpipelines subscribe <build or release url>