As you might know, it’s only possible to create app registrations secrets that are valid for a maximum of 24 months. At least in the Azure UI. The process of creating it in the UI I described in an earlier post. In this blog post, you will learn how to create an app secret valid longer than 24 months.
In the section “Summary” you can find everything you’ll need in case you don’t need all the explanations.
In general, I think it is a good idea to change a secret regularly. The Problem with the Power Platform is that we have to do a bunch of manual stuff whenever the secret expires. For example, every connection reference using the App registration needs to be reconnected manually.
Which means when you use a App registration with parts of the Power Platform you normally want the secret to be valid longer than 24 months. As mentioned this is not possible to achieve in the Azure portal as seen on the following screenshots.
The solution is to create the secret via a console. With that, one could create secrets that last as long as you’d need.
There are two different ways of doing it I know of.
Via the Azure CLI prompt in the Azure portal. As described on Tip #1404 of CRM Tip of the Day
To do so we open an Admin elevated PowerShell and type the following command.
The next step is to define the start and end date in between the secret should be valid.
First, we save today’s date in a variable called “startDate”.
$startDate = Get-Date
We then add X years to it and save it as the end date. In our case, we add 10 years.
$endDate = $startDate.AddYears(10)
Connect to Azure
To be able to execute the command we would like to run we have to connect the current session to Azure. We use the following command for that.
This will open a popup where you can sign in with the correct credentials.
Now we come to the real part of this solution.
For the following command we need the start and enddate, a custom identifier which could be whatever you’d like as well as the ObjectId of the App registration in question. This you can find in the Azure Portal in the overview of the App registration.
The command runs the mentioned cmdlet to create a new secret which starts at our defined startdate and ends at the enddate. The result is saved in a variable called “aadappsecret”.
This is just 1 of 47 articles. You can browse through all of them by going to the main page. Another possibility is to view the categories page to find more related content. You can also subscribe and get new blog posts emailed to you directly.
Privacy & Cookies Policy
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.