Skip to content

Commit

Permalink
Add storage test case (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jongio authored Jan 23, 2020
1 parent 01fd83a commit e4bde29
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion net/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

.env

nugetpush.bat
Expand Down
9 changes: 9 additions & 0 deletions net/JonGallant.Azure.Identity.Extensions.Tests/.env.temp
Original file line number Diff line number Diff line change
@@ -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=
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.30.0" />
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.0.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.ResourceManager.Fluent" Version="1.30.0" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="14.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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"));
}
}
}

0 comments on commit e4bde29

Please sign in to comment.