/// <summary> /// Uses an access token to authenticate with Azure. /// </summary> /// <param name="subscriptionId">The ID that identifies the subscription on Azure.</param> /// <param name="accessTokenKey">The secret key to use to fetch access token from the secret provider. This will be used to call the Azure management API.</param> /// <param name="secretProvider">The provider to get the client secret; using the <paramref name="accessTokenKey"/>.</param> public static LogicAppAuthentication UsingAccessToken(string subscriptionId, string accessTokenKey, ISecretProvider secretProvider) { Guard.NotNullOrWhitespace(subscriptionId, nameof(subscriptionId)); Guard.NotNullOrWhitespace(accessTokenKey, nameof(accessTokenKey)); Guard.NotNull(secretProvider, nameof(secretProvider)); return(new LogicAppAuthentication(async() => { string accessToken = await secretProvider.GetRawSecretAsync(accessTokenKey); LogicManagementClient managementClient = await AuthenticateLogicAppsManagementAsync(subscriptionId, accessToken); return managementClient; })); }
/// <summary> /// Uses the service principal to authenticate with Azure. /// </summary> /// <param name="tenantId">The ID where the resources are located on Azure.</param> /// <param name="subscriptionId">The ID that identifies the subscription on Azure.</param> /// <param name="clientId">The ID of the client or application that has access to the logic apps running on Azure.</param> /// <param name="clientSecretKey">The secret of the client or application that has access to the logic apps running on Azure.</param> /// <param name="secretProvider">The provider to get the client secret; using the <paramref name="clientSecretKey"/>.</param> public static LogicAppAuthentication UsingServicePrincipal(string tenantId, string subscriptionId, string clientId, string clientSecretKey, ISecretProvider secretProvider) { Guard.NotNullOrWhitespace(tenantId, nameof(tenantId)); Guard.NotNullOrWhitespace(subscriptionId, nameof(subscriptionId)); Guard.NotNullOrWhitespace(clientId, nameof(clientId)); Guard.NotNullOrWhitespace(clientSecretKey, nameof(clientSecretKey)); Guard.NotNull(secretProvider, nameof(secretProvider)); return(new LogicAppAuthentication(async() => { string clientSecret = await secretProvider.GetRawSecretAsync(clientSecretKey); LogicManagementClient managementClient = await AuthenticateLogicAppsManagementAsync(subscriptionId, tenantId, clientId, clientSecret); return managementClient; })); }