I am using Azure API's in C# code and used below libraries
using Microsoft.Rest; using Microsoft.Rest.Azure.Authentication;
using Microsoft.Azure.Management.DataLake.Store;
using Microsoft.Azure.Management.DataLake.StoreUploader;
using Microsoft.Azure.Management.DataLake.Analytics;
using Microsoft.Azure.Management.DataLake.Analytics.Models;
using Microsoft.WindowsAzure.Storage.Blob;
To create connection with Azure,
private static ServiceClientCredentials AuthenticateAzure(string domainName, string nativeClientAppCLIENTID)
{
// User login via interactive popup
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
// Use the client ID of an existing AAD "Native Client" application.
var activeDirectoryClientSettings = ActiveDirectoryClientSettings.UsePromptOnly(nativeClientAppCLIENTID, new Uri("urn:ietf:wg:oauth:2.0:oob"));
return UserTokenProvider.LoginWithPromptAsync(domainName, activeDirectoryClientSettings).Result;
}
Through this I got the popup, which ask my credentials. I don't want this pop-up appears every time. Is there any way to come up with this thing beside creating Azure app?
======================================
I have application ID, TenantId and other thing. Will this help me to authenticate to azure without prompt?
We can use the function
UserTokenProvider.LoginSilentAsync(nativeClientAppClientid, domainName, userName, password)
to get our credentials without pop-up. It works fine for me, the following is my test code. How to registry WebApp please refer to the document.Update:
More details steps about how to registry AD App and assign role to application, please refer to document. After that we can get
tenantId, appId, secretKey
from the Azure Portal. Then we can use Microsoft.IdentityModel.Clients.ActiveDirectory SDK to get token for api authentication.Demo code: