In the article where I describe the deployment of a Python application to Microsoft Azure, I briefly explain how to set up the Docker image push to an azure container registry (ACR in the following paragraphs).
The Problem
While creating the DevOps pipeline, it creates a service connection automatically. This represents the identity that has permission to push the image to ACR.
Under the hood, Azure DevOps creates an application registration in the Microsoft Entra ID with a secret that expires after 3 months by default.
And you don’t really notice… until it expires.
Suddenly, on day 91, you make a modification to your application, push the code and build the new Docker image.
Then the pipeline terminates with an error:
|
|
First, you don’t understand because three months is a long period. But, more importantly, you don’t know why.
The fix
The first question that comes to mind is “what is that secret that is invalid and where is it located?”.
You may try to get the ID of the service connection (found under Project settings > Service Connections) but you don’t find any reference to that in the Azure resources.
After this, a good place to start is to use the Azure CLI and read the full service connection data.
First, create yourself a PAT token under the menu next your avatar in DevOps and select “Personal Access Tokens”.
Select permission to read service connections.
Next, open the Azure portal and open the built-in CLI available to the left of the notifications icon on the top right menu.
Then run the following commands:
|
|
We get the following.
Sensitive values have been replaced with '{}' containing what it represents
|
|
The most interesting part of it all is the {registered-application-id}
. From that value, if you possess the Application Administrator
role in Microsoft Entra ID, you can find the application under the Application Registrations blade.
If you have an expired secret, then you quickly noticed a red toast notification bar at the top of the resource inviting you to “create a new secret”.
It isn’t the way to go.
Instead, go to Azure DevOps and load the service connection again and go into edit mode.
By clicking Save, DevOps will create a new secret key/value (and override any you may have created manually).
From there, you can resume the CI by triggering a manual build of the pipeline. It’ll build and push the new Docker image to the ACR.
Unfortunately, as of November 2024, I could find no other way. Don’t trust “Click the Verify button” some articles and even the official Microsoft documentation talks about, as it became obsolete at some point. The Save button does it all.
You’ll need to perform this manual action every three months.
Unless Microsoft makes it automatic or more explicit?
Follow me
I appreciate you taking the time to read this article. Make sure to follow me on X, subscribe to my Substack publication and bookmark my blog to read more in the future.