diff --git a/README.md b/README.md index 5430598..3063411 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,21 @@ using Microsoft.Azure.Management.CosmosDB.Models; var client = new CosmosDBManagementClient(new DefaultAzureMgmtCredential()); ``` +### Storage + +``` +dotnet add package JonGallant.Azure.Identity.Extensions +dotnet add package Microsoft.Azure.Management.Storage --version 14.3.0 +``` + +Use DefaultAzureMgmtCredential in place of ServiceClientCredential: +```csharp +using JonGallant.Azure.Identity.Extensions; +using Microsoft.Azure.Management.Storage; + +var client = new StorageManagementClient(new DefaultAzureMgmtCredential()); +``` + ## DefaultAzureFluentCredential The `DefaultAzureFluentCredential` class allows you to use all the goodness of `Azure.Identity.DefaultAzureCredential` in the [Azure Management **Fluent** libraries](https://github.com/Azure/azure-libraries-for-net). You can use it in place of `AzureCredentials` when calling your Azure Management Fluent APIs. diff --git a/net/.gitignore b/net/.gitignore index c5036cf..4f8bc5c 100644 --- a/net/.gitignore +++ b/net/.gitignore @@ -1,4 +1,3 @@ - .env nugetpush.bat diff --git a/net/JonGallant.Azure.Identity.Extensions.Tests/.env.temp b/net/JonGallant.Azure.Identity.Extensions.Tests/.env.temp new file mode 100644 index 0000000..a6f6812 --- /dev/null +++ b/net/JonGallant.Azure.Identity.Extensions.Tests/.env.temp @@ -0,0 +1,9 @@ +AZURE_CLIENT_ID= +AZURE_CLIENT_SECRET= +AZURE_TENANT_ID= +AZURE_SUBSCRIPTION_ID= +AZURE_RESOURCE_GROUP= +APPINSIGHTS_NAME= +COSMOSDB_NAME= +AZURE_REGION= +AZURE_STORAGE_ACCOUNT_NAME= diff --git a/net/JonGallant.Azure.Identity.Extensions.Tests/JonGallant.Azure.Identity.Extensions.Tests.csproj b/net/JonGallant.Azure.Identity.Extensions.Tests/JonGallant.Azure.Identity.Extensions.Tests.csproj index 4dacc94..1987a9d 100644 --- a/net/JonGallant.Azure.Identity.Extensions.Tests/JonGallant.Azure.Identity.Extensions.Tests.csproj +++ b/net/JonGallant.Azure.Identity.Extensions.Tests/JonGallant.Azure.Identity.Extensions.Tests.csproj @@ -13,6 +13,7 @@ + diff --git a/net/JonGallant.Azure.Identity.Extensions.Tests/Mgmt/StorageTests.cs b/net/JonGallant.Azure.Identity.Extensions.Tests/Mgmt/StorageTests.cs new file mode 100644 index 0000000..233c590 --- /dev/null +++ b/net/JonGallant.Azure.Identity.Extensions.Tests/Mgmt/StorageTests.cs @@ -0,0 +1,27 @@ +using DotNetEnv; +using Microsoft.Azure.Management.Storage; +using System; +using Xunit; + +namespace JonGallant.Azure.Identity.Extensions.Tests.Mgmt +{ + public class StorageTests + { + [Fact] + public void ReadStorageAccountLocationTest() + { + // Pre-req: Storage account created. + Env.Load("../../../.env"); + + var client = new StorageManagementClient(new DefaultAzureMgmtCredential()); + + client.SubscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID"); + + var props = client.StorageAccounts.GetProperties( + Environment.GetEnvironmentVariable("AZURE_RESOURCE_GROUP"), + Environment.GetEnvironmentVariable("AZURE_STORAGE_ACCOUNT_NAME")); + + Assert.Equal(props.Location, Environment.GetEnvironmentVariable("AZURE_REGION")); + } + } +}