This repository contains a series of bash scripts and JSON templates used to create and maintain a simple Rig implementation on Azure. The technologies used for this Rig implementation consist primarily of PaaS offerings in Azure as well managed Azure DevOps pipelines.
- Backlog: https://digitalrig.atlassian.net/jira/software/projects/ARI/boards/437/backlog
- Live DevOps project: https://dev.azure.com/BuilditAzureSandbox/BuilditAzureRig
- Integration: https://azurerigappservicedev.azurewebsites.net/
- Staging: https://azurerigappservicestage.azurewebsites.net/
- Production: https://azurerigappserviceprod.azurewebsites.net/
A Personal Access Token (PAT) is required to authorize API requests. To grant a PAT follow these steps:
- Go to https://dev.azure.com/{organization} to get to the DevOps organization homepage.
- Click on your user icon in the top right corner and click the security tab from the dropdown menu.
- Click new token and provide a unique name and access scope.
- Copy and store the token in a secure location.
sample command (username is normally the email address of the user) {personalaccesstoken} is the PAT obtained from the steps above. {organization} is the name of the organization implementing the rig.
curl -u username:{personalaccesstoken} "https://dev.azure.com/{organization}/_apis/projects?api-version=5.0"
A PAT for the Azure pipeline to access github must be created and added to the project:
- Sign into https://github.com/settings/tokens .
- Click generate new token with the scopes -- repo, read:user, user:email, admin:repo_hook .
- Copy and store the token in a secure location.
- Clone this repository
- run the command:
make create-populateProject
- Respond to the step by step prompts for parameter values
- Resource Group and Pipelines will be created and a build will be kicked off (may take a few minutes)
- The hosted application is containerized
- The Dockerfile runs any unit tests and exports the results in JUnit format
- The Dockerfile contains an intermediate container step that AZCopies the test results to blob storage. (see example)
- The application to deploy exists in a GitHub repository
The Azure Rig makes use of a number of different Azure features including:
- Azure Resource Groups
- Azure Web App for containers
- Azure Container Registries
- Azure DevOps Pipelines
The major components of this Rig are:
- A common resource group shared by all enviornments consiting of the ACR and storage account.
- A DevOps build pipeline
- A DevOpt release pipeline
- Three resource groups (one per enviornment) for releasing the application
The high level steps for these pipelines:
- Build and containerize the application from a Dockerfile, this includes running unit tests and exporting the results to blob storage.
- Tag the image according to the current branch being built (dev, feature, master, etc.)
- Download the test results from blob storage
- Publish the test results so they become associated with the build
- Push the container image to Azure Container Registry.
Each environment
- Creates the deployment environment resource group (if not exists)
- Creates or Updates the WepApp service container
An integration environment is triggered to be created after a successful build from a development branch
A change to the master branch triggers the creation of a staging environment and upon passing an approval gate a production environment is created with the image that passed staging
In order to create build and release pipelines, the Azure DevOps Services REST API must be used API Documentation
The goal of the Azure Rig is not to overwhelm the user with an endless array of parameters and options required in order to get started. That being said there are still some inputs that are required from the user.
- Location (ex. Central US, East US, etc)
- DevOps Username
- DevOps PAT (see above)
- GitHub PAT (see above)
- Base name for the resource groups that get generated
- Need to extract more parameters out of our templates
- Likely need to move to REST API or ARM templates for creating Azure resources
- Application Insights alerts can't be created via the
az
CLI
- Application Insights alerts can't be created via the
- Move away from BASH scripts and write utilities in code.
curl
&jq
just aren't sufficient to deal w/ the chattiness of the Azure & Azure DevOps services.
The Azure Rig supports two database options at present:
- An Azure SQL Database can be provisioned in the resource group.
- Deploy SQL Server Container to AKS cluster with persisted volume.