- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 03-16-2022 02:44 PM
Starting with the Rome release, running a MID server as a container is fully-supported. Here's an example of how you can manage your MID configuration as code, with an Azure pipeline to build the image.
NOTE: the process I had to follow did not leverage the "Build Docker Image" wizard offered by Azure because I don't have the requisite Azure AD access it requires to create a new application; if you have Azure AD admin rights in your Azure environment, this process should be even easier for you 🙂 .
GitHub Repository
I created a GitHub repository by starting with the Docker recipe provided by my ServiceNow instance, underneath MID Server->Downloads. I added the following file, named "azure-pipelines.yml", to define the Azure pipeline behavior.
trigger:
- main
pool:
vmImage: 'windows-2019'
variables:
- group: docker-vars
- name: imageName
value: 'sandiego-win-mid-container'
- name: repoName
value: 'myrepo.azurecr.io'
steps:
- script: |
echo Logging in to ACR
echo $(AZURE_SP_SECRET) | docker login $(repoName)--username $(AZURE_SP_ID) --password-stdin
echo Building the Docker image...
docker build -t $(imageName):latest .
docker tag $(imageName):latest $(repoName)/$(imageName):latest
echo Pushing the Docker image...
docker push $(repoName)/$(imageName):latest
Azure Container Registry
To create a registry to hold my MID server images, I use a command like this:
az acr create --name <Registry Name> --resource-group <myresourcegroup> --sku Standard
Azure Variables
Because I lack the Azure AD privileges to create a new application, I need to populate credentials for logging into my Azure container registry. I did this by doing the following:
- I obtained credentials for an Azure Service Principal which has Contributor access to the registry created above
- I navigated to "Library" under my Azure DevOps project and clicking "+ Variable Group". I named the variable group "docker-vars" and populate it as follows:
Name | Value |
AZURE_SP_ID | <client ID of Azure Service Principal> |
AZURE_SP_SECRET | <secret value for Azure Service Principal> (designated as a "secret" value) |
Azure Pipeline
Azure's built-in GitHub integration makes pipeline creation pretty easy if your code is in GitHub. After clicking "New Pipeline" in my Azure DevOps project, I select "GitHub" as the source.
The Azure DevOps console automatically takes me to GitHub to select a repository and provide the needed permissions. It also brings in the azure-pipelines.yaml file, as long as I've committed it and pushed it up to GitHub. At this point I can attempt an image build by clicking the "Run" button in the upper right.
The bulk of the build activity occurs in the "CmdLine" step of the job; hopefully it ends with a bunch of push lines, like this:
Now that I have my image available in a repo, I can deploy it to my container runtimes. I generally manage that via Kubernetes. I relied on this blog article by my teammate Mike Gallagher for an example of how to construct a suitable deployment spec. As this example is a Windows MID image, I did have to jump through some hoops to get a Windows nodegroup created and added to my cluster. I also had to add a nodeSelector section in order to have the cluster chose a Windows node, e.g.
nodeSelector:
kubernetes.io/os: "windows"