Skip to content

Commit

Permalink
mgmt, update readme (#13674)
Browse files Browse the repository at this point in the history
* update readme

* revert to DefaultAzureCredentialBuilder, authorityHost available after azure-identity 1.1.0

* add sample for Azure Germany
  • Loading branch information
weidongxu-microsoft authored Aug 3, 2020
1 parent 7d9e028 commit 56165e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sdk/management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ With above configuration, `azure` client can be authenticated by following code:
```java
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
TokenCredential credential = new DefaultAzureCredentialBuilder()
.authorityHost(profile.environment().getActiveDirectoryEndpoint())
.build();
Azure azure = Azure
.authenticate(credential, profile)
.withDefaultSubscription();
```

The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise.

See [Authentication][authenticate] for more options.

### Code snippets and samples
Expand Down
11 changes: 11 additions & 0 deletions sdk/management/docs/AUTH.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ Sample code to create a `AzureProfile`:
AzureProfile profile = new AzureProfile("<YOUR_TENANT_ID>", "<YOUR_SUBSCRIPTION_ID>", AzureEnvironment.AZURE);
```

The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise.

Sample code for Azure Germany, with `EnvironmentCredential`:

```java
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE_GERMANY);
EnvironmentCredential credential = new EnvironmentCredentialBuilder()
.authorityHost(profile.environment().getActiveDirectoryEndpoint())
.build();
```

### Authenticating with default HttpPipeline

Once the `TokenCredential` and `AzureProfile` are ready, you can move forward with below authenticating code. It helps build http pipeline internally with [default configuration](https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resources/mgmt/src/main/java/com/azure/resourcemanager/resources/fluentcore/utils/HttpPipelineProvider.java#L43).
Expand Down

0 comments on commit 56165e7

Please sign in to comment.