Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Last active July 5, 2022 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guitarrapc/6aa3810bc84d95eefaec6980c2cfb901 to your computer and use it in GitHub Desktop.
Save guitarrapc/6aa3810bc84d95eefaec6980c2cfb901 to your computer and use it in GitHub Desktop.
Create AzureCredntials for Azure SDK for .NET
using Microsoft.Azure.Management.PostgreSQL.FlexibleServers;
using Microsoft.Azure.Management.ResourceManager.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent.Authentication;
using System.Threading.Tasks;
// SdkContext から生成する場合
// var cred = SdkContext.AzureCredentialsFactory.FromMSI(new MSILoginInformation(MSIResourceType.AppService), AzureEnvironment.AzureGlobalCloud);
// var cred = SdkContext.AzureCredentialsFactory.FromServicePrincipal("<clientId>", "<clientSecret>", "<tenantId>", AzureEnvironment.AzureGlobalCloud);
// new AzureCredentials でインスタンスを渡して生成する場合
var cred = new AzureCredentials(new ServicePrincipalLoginInformation
{
ClientId = "<clientid>",
ClientSecret = "<clientSecret>",
}, "<tenantid>", AzureEnvironment.AzureGlobalCloud);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment