Skip to content

Commit

Permalink
Mgmt: update Azure in docs (Azure#15416)
Browse files Browse the repository at this point in the history
* update Azure in docs

* fix some error
  • Loading branch information
ChenTanyi authored Sep 21, 2020
1 parent 87f8e3f commit e044bca
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions sdk/resourcemanager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
TokenCredential credential = new DefaultAzureCredentialBuilder()
.authorityHost(profile.environment().getActiveDirectoryEndpoint())
.build();
Azure azure = Azure
AzureResourceManager azure = AzureResourceManager
.authenticate(credential, profile)
.withDefaultSubscription();
```
Expand Down Expand Up @@ -253,7 +253,7 @@ azure.virtualMachines().listByResourceGroupAsync(rgName)
You can customize various aspects of the client.

```java
Azure azure = Azure
AzureResourceManager azure = AzureResourceManager
.configure()
.withHttpClient(customizedHttpClient)
.withPolicy(additionalPolicy)
Expand Down Expand Up @@ -301,7 +301,7 @@ locate the root issue. View the [logging][logging] wiki for guidance about enabl

Sample code to enable logging in Azure Management Libraries.
```java
Azure azure = Azure
AzureResourceManager azure = AzureResourceManager
.configure()
.withLogLevel(HttpLogDetailLevel.BASIC)
.authenticate(credential, profile)
Expand Down
12 changes: 6 additions & 6 deletions sdk/resourcemanager/docs/AUTH.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ EnvironmentCredential credential = new EnvironmentCredentialBuilder()
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/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/fluentcore/utils/HttpPipelineProvider.java#L43).

```java
Azure azure = Azure.authenticate(credential, profile).withDefaultSubscription();
AzureResourceManager azure = AzureResourceManager.authenticate(credential, profile).withDefaultSubscription();
```

The `Authenticated` class provides access to a subset of Azure APIs that do not require a specific subscription. If the profile does not contain a subscription, you can select a subscription via [`Authenticated::subscriptions`](https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/azure-resourcemanager/src/main/java/com/azure/resourcemanager/AzureResourceManager.java#L200). Similarly, you can select a tenant via [`Authenticated::tenants`](https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/azure-resourcemanager/src/main/java/com/azure/resourcemanager/AzureResourceManager.java#L207).

```java
Azure.Authenticated authenticated = Azure.authenticate(credential, profile);
AzureResourceManager.Authenticated authenticated = AzureResourceManager.authenticate(credential, profile);
String subscriptionId = authenticated.subscriptions().list().iterator().next().subscriptionId();
Azure azure = authenticated.withSubscription(subscriptionId);
AzureResourceManager azure = authenticated.withSubscription(subscriptionId);
```

## Advanced Authentication
Expand Down Expand Up @@ -117,13 +117,13 @@ HttpPipeline httpPipeline = new HttpPipelineBuilder()
Once your custom configurations are ready, you can move forward with below authenticating code. It would execute the settings you apply in the custom HttpPipeline.

```java
Azure azure = Azure.authenticate(httpPipeline, profile).withDefaultSubscription();
AzureResourceManager azure = AzureResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
```

If you want to configure part of http pipeline instead of building new one, you may set via `Azure::configure`.
If you want to configure part of http pipeline instead of building new one, you may set via `AzureResourceManager::configure`.

```java
Azure azure = Azure.configure()
AzureResourceManager azure = AzureResourceManager.configure()
.withPolicy(customPolicy)
.withRetryPolicy(customRetryPolicy)
.withHttpClient(httpClient)
Expand Down
4 changes: 2 additions & 2 deletions sdk/resourcemanager/docs/MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Azure azure = Azure.configure()
**Equivalent in new version (`com.azure.resourcemanager.**`)**

```java
Azure azure = Azure.configure()
AzureResourceManager azure = AzureResourceManager.configure()
.withPolicy(new CustomizedPolicy())
.authenticate(credential, profile)
.withDefaultSubscription();
Expand Down Expand Up @@ -123,7 +123,7 @@ HttpClient client = new OkHttpAsyncHttpClientBuilder()
.proxy(new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("127.0.0.1", 8888)))
.build();

Azure azure = Azure.configure()
AzureResourceManager azure = AzureResourceManager.configure()
.withHttpClient(client)
.authenticate(credential, profile)
.withDefaultSubscription();
Expand Down
4 changes: 2 additions & 2 deletions sdk/resourcemanager/docs/SAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

### Azure Authentication

The `Azure` class is the simplest entry point for creating and interacting with Azure resources.
The `AzureResourceManager` class is the simplest entry point for creating and interacting with Azure resources.

```java
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
TokenCredential credential = new DefaultAzureCredentialBuilder()
.authorityHost(profile.environment().getActiveDirectoryEndpoint())
.build();
Azure azure = Azure
AzureResourceManager azure = AzureResourceManager
.authenticate(credential, profile)
.withDefaultSubscription();
```
Expand Down
2 changes: 1 addition & 1 deletion sdk/resourcemanager/docs/THROTTLING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ By default, `RetryPolicy` is added to the HTTP pipeline. It will automatically r
HTTP policy `ResourceManagerThrottlingPolicy` can be added to HTTP pipeline, to provide real-time information on remaining requests, before throttling kick-in.

```java
Azure azure = Azure.configure()
AzureResourceManager azure = AzureResourceManager.configure()
.withPolicy(new ResourceManagerThrottlingPolicy((response, throttlingInfo) -> {
// throttlingInfo.getRateLimit()
}))
Expand Down

0 comments on commit e044bca

Please sign in to comment.