简体   繁体   中英

Silent azure authentication in c# with “personal account”

I want to use the Microsoft.Azure.Management - Tools in C# to deploy resources in Azure. Unfortunately, I have a so called "personal account", which means that I can do almost everything in azure like creating virtual machines, resource groups etc. but I am not allowed to access the "Azure Active Directory". When I log in into Azure, I have to choose "Personal account", and then enter my credentials. I can't register any application when I choose "Azure Active Directory"

My aim is to have a unit test in C# that deploys some resources into azure, without entering my username/password. That means I want to authenticate silently. Authentication would be using the Microsoft.Azure.Management - Libraries, eg with Microsoft.Rest.Azure.Authentication.UserTokenProvider.LoginSilentAsync(...) or Microsoft.Azure.Management.Fluent.Azure.Authenticate(...)

I played around with the libraries for a while, but now I am stucked - as far as I understood, I had to register an application under [ https://apps.dev.microsoft.com/] and use the generated clientId, clientSecret & tenantId to authenticate. I couldn't make it work. I read some more documentation, including OAuth2, the new v2.0 Azure Endpoint, and other stuff, but I always failed to authenticate. The most documentation is using the Azure Active Directory, which doesn't work for me (as it is a "personal account")

Can anyone give me a hint how I can silently (so without any pop-up questioning me for username / password) authenticate in Azure within a C# unit test or console application, using my "personal account"?

Can anyone give me a hint how I can silently (so without any pop-up questioning me for username / password) authenticate in Azure within a C# unit test or console application, using my "personal account"?

According to your description, it indicates that you have no right permissions to perform registry Azure AD Application. You could check the App registrations setting . If set to Yes , non-admin users can register AD apps. If the app registrations setting is set to No , only admin users can register apps.

In your case, you could connect to your subscription administrator to add your account as an administrator or ask your subscription administrator to registry an Azure AD application and share clientId, client secret and also need to assign corrosponding role to access resource.

More detail info please refer to Use portal to create an Azure Active Directory application and service principal that can access resources .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM