To automate our build process, i was looking for a possibility to change the “Reply URL” of an existing Active Directory application via a Powershell script.
The official documentation just describes a way, how to change it with help of the web portal.
There is already a Github issue about this topic. But maybe someone faced a similar problem in the past and solved it?
As an alternative, you can put the following script in a console application and then call this program from your Powershell script.
First of all, include the nuget package
//First, log in into Azure:
Uri servicePointUri = new Uri("https://graph.windows.net");
Uri serviceRoot = new Uri(servicePointUri, "YourTenantId");
ActiveDirectoryClient activeDirectoryClient = new ActiveDirectoryClient(serviceRoot,
async () => await AcquireTokenAsyncForUser("YourTenant.onmicrosoft.com", "ClientIdForThisApplication"));
//A popup will now be shown to you, requiring you to log in into the AAD.
//Find your application
var existingApp = activeDirectoryClient.Applications.Where(s => s.DisplayName == "NameOfYourApplication").Take(1).ExecuteAsync().Result;
if (existingApp != null && existingApp.CurrentPage != null && existingApp.CurrentPage.Count == 1)
var app = existingApp.CurrentPage.First();
//Change the Reply Url
A bit more details about the things you will need to change:
YourTenantId, this is the GUID that’s used to identify your azure active directory (AAD).
YourTenant.onmicrosoft.com, basicly this is the name of your AAD followed by “.onmicrosoft.com”.
ClientIdForThisApplication, you will have to add the above console application in your AAD under applications manually. (as a Native Client Application). In the Configure tab, you will find the Client ID for this application. This only needs to be done once, you can keep using this application (and its Client Id) for all your builds.
NameOfYourApplication, name of the application you wish to change, as it is known in your AAD.
http://YourNewReplyUrl/, your new reply url.
(Small disclosure, I’ve scrapped the above code together from my existing code, I think I’ve copied all what’s required, but I haven’t tested the above result.)