in SamplesV1/ParameterizedPipelinesForAzureML/DeployDataFactory/DeployDataFactory/Utilities.cs [99:131]
public static string GetAuthorizationHeader()
{
AuthenticationResult result = null;
var thread = new Thread(() =>
{
try
{
var context = new AuthenticationContext(ConfigurationManager.AppSettings["ActiveDirectoryEndpoint"] + ConfigurationManager.AppSettings["ActiveDirectoryTenantId"]);
result = context.AcquireToken(
resource: ConfigurationManager.AppSettings["WindowsManagementUri"],
clientId: ConfigurationManager.AppSettings["AdfClientId"],
redirectUri: new Uri(ConfigurationManager.AppSettings["RedirectUri"]),
promptBehavior: PromptBehavior.Always);
}
catch (Exception threadEx)
{
Console.WriteLine(threadEx.Message);
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Name = "AcquireTokenThread";
thread.Start();
thread.Join();
if (result != null)
{
return result.AccessToken;
}
throw new InvalidOperationException("Failed to acquire token");
}