Skip to content

Commit 8f4cd16

Browse files
mgmt, improve readme in packages (Azure#17251)
1 parent 28ec448 commit 8f4cd16

File tree

47 files changed

+1957
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1957
-47
lines changed

sdk/resourcemanager/README.md

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ In addition, Azure subscription ID can be configured via environment variable `A
7777

7878
With above configuration, `azure` client can be authenticated by following code:
7979

80+
<!-- embedme ./azure-resourcemanager/src/samples/java/com/azure/resourcemanager/ReadmeSamples.java#L62-L68 -->
8081
```java
8182
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
8283
TokenCredential credential = new DefaultAzureCredentialBuilder()
@@ -142,84 +143,84 @@ Services in preview
142143

143144
You can create a virtual machine instance, together with required virtual network and ip address created automatically.
144145

146+
<!-- embedme ./azure-resourcemanager/src/samples/java/com/azure/resourcemanager/ReadmeSamples.java#L95-L105 -->
145147
```java
146148
VirtualMachine linuxVM = azure.virtualMachines().define("myLinuxVM")
147149
.withRegion(Region.US_EAST)
148150
.withNewResourceGroup(rgName)
149151
.withNewPrimaryNetwork("10.0.0.0/28")
150152
.withPrimaryPrivateIPAddressDynamic()
151-
.withNewPrimaryPublicIPAddress("mylinuxvm")
152-
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
153-
.withRootUsername("tirekicker")
154-
.withSsh(sshKey)
153+
.withoutPrimaryPublicIPAddress()
154+
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_18_04_LTS)
155+
.withRootUsername("<username>")
156+
.withSsh("<ssh-key>")
155157
.withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
156158
.create();
157159
```
158160

159161
Update.
160162

163+
<!-- embedme ./azure-resourcemanager/src/samples/java/com/azure/resourcemanager/ReadmeSamples.java#L107-L109 -->
161164
```java
162165
linuxVM.update()
163-
.withNewDataDisk(20, lun, CachingTypes.READ_WRITE)
166+
.withNewDataDisk(10, 0, CachingTypes.READ_WRITE)
164167
.apply();
165168
```
166169

167170
### Dependency across Azure resources
168171

169172
You can create a function app, together with required storage account and app service plan created on specification.
170173

174+
<!-- embedme ./azure-resourcemanager/src/samples/java/com/azure/resourcemanager/ReadmeSamples.java#L115-L135 -->
171175
```java
172176
Creatable<StorageAccount> creatableStorageAccount = azure.storageAccounts()
173-
.define(storageAccountName)
177+
.define("<storage-account-name>")
174178
.withRegion(Region.US_EAST)
175179
.withExistingResourceGroup(rgName)
176180
.withGeneralPurposeAccountKindV2()
177181
.withSku(StorageAccountSkuType.STANDARD_LRS);
178-
179182
Creatable<AppServicePlan> creatableAppServicePlan = azure.appServicePlans()
180-
.define(appServicePlanName)
183+
.define("<app-service-plan-name>")
181184
.withRegion(Region.US_EAST)
182185
.withExistingResourceGroup(rgName)
183186
.withPricingTier(PricingTier.STANDARD_S1)
184187
.withOperatingSystem(OperatingSystem.LINUX);
185-
186-
FunctionApp linuxFunctionApp = azure.functionApps().define(functionAppName)
188+
FunctionApp linuxFunctionApp = azure.functionApps().define("<function-app-name>")
187189
.withRegion(Region.US_EAST)
188190
.withExistingResourceGroup(rgName)
189191
.withNewLinuxAppServicePlan(creatableAppServicePlan)
190192
.withBuiltInImage(FunctionRuntimeStack.JAVA_8)
191193
.withNewStorageAccount(creatableStorageAccount)
192194
.withHttpsOnly(true)
193-
.withAppSetting("WEBSITE_RUN_FROM_PACKAGE", functionAppPackageUrl)
195+
.withAppSetting("WEBSITE_RUN_FROM_PACKAGE", "<function-app-package-url>")
194196
.create();
195197
```
196198

197199
### Batch Azure resource provisioning
198200

199201
You can batch create and delete managed disk instances.
200202

203+
<!-- embedme ./azure-resourcemanager/src/samples/java/com/azure/resourcemanager/ReadmeSamples.java#L141-L152 -->
201204
```java
202205
List<String> diskNames = Arrays.asList("datadisk1", "datadisk2");
203-
204206
List<Creatable<Disk>> creatableDisks = diskNames.stream()
205207
.map(diskName -> azure.disks()
206208
.define(diskName)
207209
.withRegion(Region.US_EAST)
208210
.withExistingResourceGroup(rgName)
209211
.withData()
210-
.withSizeInGB(1)
212+
.withSizeInGB(10)
211213
.withSku(DiskSkuTypes.STANDARD_LRS))
212214
.collect(Collectors.toList());
213-
214215
Collection<Disk> disks = azure.disks().create(creatableDisks).values();
215-
216216
azure.disks().deleteByIds(disks.stream().map(Disk::id).collect(Collectors.toList()));
217217
```
218218

219219
### Integration with Azure role-based access control
220220

221221
You can assign Contributor for an Azure resource to a service principal.
222222

223+
<!-- embedme ./azure-resourcemanager/src/samples/java/com/azure/resourcemanager/ReadmeSamples.java#L160-L166 -->
223224
```java
224225
String raName = UUID.randomUUID().toString();
225226
RoleAssignment roleAssignment = azure.accessManagement().roleAssignments()
@@ -234,8 +235,9 @@ RoleAssignment roleAssignment = azure.accessManagement().roleAssignments()
234235

235236
You can create storage account, then blob container, in reactive programming.
236237

238+
<!-- embedme ./azure-resourcemanager/src/samples/java/com/azure/resourcemanager/ReadmeSamples.java#L172-L185 -->
237239
```java
238-
azure.storageAccounts().define(storageAccountName)
240+
azure.storageAccounts().define("<storage-account-name>")
239241
.withRegion(Region.US_EAST)
240242
.withNewResourceGroup(rgName)
241243
.withSku(StorageAccountSkuType.STANDARD_LRS)
@@ -248,28 +250,29 @@ azure.storageAccounts().define(storageAccountName)
248250
.withPublicAccess(PublicAccess.BLOB)
249251
.createAsync()
250252
)
251-
...
253+
//...
252254
```
253255

254256
You can operate on virtual machines in parallel.
255257

258+
<!-- embedme ./azure-resourcemanager/src/samples/java/com/azure/resourcemanager/ReadmeSamples.java#L192-L194 -->
256259
```java
257260
azure.virtualMachines().listByResourceGroupAsync(rgName)
258261
.flatMap(VirtualMachine::restartAsync)
259-
...
262+
//...
260263
```
261264

262265
### Configurable client
263266

264-
You can customize various aspects of the client.
267+
You can customize various aspects of the client and pipeline.
265268

269+
<!-- embedme ./azure-resourcemanager/src/samples/java/com/azure/resourcemanager/ReadmeSamples.java#L206-L210 -->
266270
```java
267271
AzureResourceManager azure = AzureResourceManager
268272
.configure()
269273
.withHttpClient(customizedHttpClient)
270274
.withPolicy(additionalPolicy)
271-
.withConfiguration(customizedConfiguration)
272-
...
275+
//...
273276
```
274277

275278
### Include single package
@@ -289,9 +292,11 @@ For example, here is sample maven dependency for Compute package.
289292
[//]: # ({x-version-update-end})
290293

291294
Sample code to create the authenticated client.
295+
296+
<!-- embedme ./azure-resourcemanager/src/samples/java/com/azure/resourcemanager/ReadmeSamples.java#L88-L89 -->
292297
```java
293-
ComputeManager client = ComputeManager.authenticate(credential, profile);
294-
client.virtualMachines().listByResourceGroup(rgName);
298+
ComputeManager manager = ComputeManager.authenticate(credential, profile);
299+
manager.virtualMachines().list();
295300
```
296301

297302
## Troubleshooting
@@ -314,6 +319,8 @@ their resolution. The logs produced will capture the flow of an application befo
314319
locate the root issue. View the [logging][logging] wiki for guidance about enabling logging.
315320

316321
Sample code to enable logging in Azure Management Libraries.
322+
323+
<!-- embedme ./azure-resourcemanager/src/samples/java/com/azure/resourcemanager/ReadmeSamples.java#L76-L80 -->
317324
```java
318325
AzureResourceManager azure = AzureResourceManager
319326
.configure()

sdk/resourcemanager/azure-resourcemanager-appplatform/README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ For documentation on how to use this package, please see [Azure Management Libra
88

99
### Prerequisites
1010

11-
- Java Development Kit (JDK) with version 8 or above
11+
- [Java Development Kit (JDK)][jdk] with version 8 or above
12+
- [Azure Subscription][azure_subscription]
1213

1314
### Adding the package to your product
1415

@@ -22,10 +23,46 @@ For documentation on how to use this package, please see [Azure Management Libra
2223
```
2324
[//]: # ({x-version-update-end})
2425

26+
### Include the recommended packages
27+
28+
Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client.
29+
30+
[Azure Identity][azure_identity] package and [Azure Core Netty HTTP][azure_core_http_netty] package provide the default implementation.
31+
32+
### Authentication
33+
34+
By default, Azure Active Directory token authentication depends on correct configure of following environment variables.
35+
36+
- `AZURE_CLIENT_ID` for Azure client ID.
37+
- `AZURE_TENANT_ID` for Azure tenant ID.
38+
- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate.
39+
40+
In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`.
41+
42+
With above configuration, `azure` client can be authenticated by following code:
43+
44+
<!-- embedme ./src/samples/java/com/azure/resourcemanager/appplatform/ReadmeSamples.java#L21-L26 -->
45+
```java
46+
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
47+
TokenCredential credential = new DefaultAzureCredentialBuilder()
48+
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
49+
.build();
50+
AppPlatformManager manager = AppPlatformManager
51+
.authenticate(credential, profile);
52+
```
53+
54+
The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise.
55+
56+
See [Authentication][authenticate] for more options.
57+
2558
## Key concepts
2659

60+
See [API design][design] for general introduction on design and key concepts on Azure Management Libraries.
61+
2762
## Examples
2863

64+
See [Samples][sample] for code snippets and samples.
65+
2966
## Troubleshooting
3067

3168
## Next steps
@@ -40,3 +77,12 @@ Azure Projects Contribution Guidelines](https://azure.github.io/guidelines.html)
4077
1. Commit your changes (`git commit -am 'Add some feature'`)
4178
1. Push to the branch (`git push origin my-new-feature`)
4279
1. Create new Pull Request
80+
81+
<!-- LINKS -->
82+
[jdk]: https://docs.microsoft.com/java/azure/jdk/
83+
[azure_subscription]: https://azure.microsoft.com/free/
84+
[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/identity/azure-identity
85+
[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/core/azure-core-http-netty
86+
[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/AUTH.md
87+
[sample]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/SAMPLE.md
88+
[design]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/DESIGN.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.resourcemanager.appplatform;
5+
6+
import com.azure.core.credential.TokenCredential;
7+
import com.azure.core.management.AzureEnvironment;
8+
import com.azure.core.management.profile.AzureProfile;
9+
import com.azure.identity.DefaultAzureCredentialBuilder;
10+
11+
/**
12+
* WARNING: MODIFYING THIS FILE WILL REQUIRE CORRESPONDING UPDATES TO README.md FILE. LINE NUMBERS
13+
* ARE USED TO EXTRACT APPROPRIATE CODE SEGMENTS FROM THIS FILE. ADD NEW CODE AT THE BOTTOM TO AVOID CHANGING
14+
* LINE NUMBERS OF EXISTING CODE SAMPLES.
15+
*
16+
* Code samples for the README.md
17+
*/
18+
public class ReadmeSamples {
19+
20+
public void authenticate() {
21+
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
22+
TokenCredential credential = new DefaultAzureCredentialBuilder()
23+
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
24+
.build();
25+
AppPlatformManager manager = AppPlatformManager
26+
.authenticate(credential, profile);
27+
}
28+
}

sdk/resourcemanager/azure-resourcemanager-appservice/README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ For documentation on how to use this package, please see [Azure Management Libra
88

99
### Prerequisites
1010

11-
- Java Development Kit (JDK) with version 8 or above
11+
- [Java Development Kit (JDK)][jdk] with version 8 or above
12+
- [Azure Subscription][azure_subscription]
1213

1314
### Adding the package to your product
1415

@@ -22,10 +23,46 @@ For documentation on how to use this package, please see [Azure Management Libra
2223
```
2324
[//]: # ({x-version-update-end})
2425

26+
### Include the recommended packages
27+
28+
Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client.
29+
30+
[Azure Identity][azure_identity] package and [Azure Core Netty HTTP][azure_core_http_netty] package provide the default implementation.
31+
32+
### Authentication
33+
34+
By default, Azure Active Directory token authentication depends on correct configure of following environment variables.
35+
36+
- `AZURE_CLIENT_ID` for Azure client ID.
37+
- `AZURE_TENANT_ID` for Azure tenant ID.
38+
- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate.
39+
40+
In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`.
41+
42+
With above configuration, `azure` client can be authenticated by following code:
43+
44+
<!-- embedme ./src/samples/java/com/azure/resourcemanager/appservice/ReadmeSamples.java#L21-L26 -->
45+
```java
46+
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
47+
TokenCredential credential = new DefaultAzureCredentialBuilder()
48+
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
49+
.build();
50+
AppServiceManager manager = AppServiceManager
51+
.authenticate(credential, profile);
52+
```
53+
54+
The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise.
55+
56+
See [Authentication][authenticate] for more options.
57+
2558
## Key concepts
2659

60+
See [API design][design] for general introduction on design and key concepts on Azure Management Libraries.
61+
2762
## Examples
2863

64+
See [Samples][sample] for code snippets and samples.
65+
2966
## Troubleshooting
3067

3168
## Next steps
@@ -40,3 +77,12 @@ Azure Projects Contribution Guidelines](https://azure.github.io/guidelines.html)
4077
1. Commit your changes (`git commit -am 'Add some feature'`)
4178
1. Push to the branch (`git push origin my-new-feature`)
4279
1. Create new Pull Request
80+
81+
<!-- LINKS -->
82+
[jdk]: https://docs.microsoft.com/java/azure/jdk/
83+
[azure_subscription]: https://azure.microsoft.com/free/
84+
[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/identity/azure-identity
85+
[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/core/azure-core-http-netty
86+
[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/AUTH.md
87+
[sample]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/SAMPLE.md
88+
[design]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/DESIGN.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.resourcemanager.appservice;
5+
6+
import com.azure.core.credential.TokenCredential;
7+
import com.azure.core.management.AzureEnvironment;
8+
import com.azure.core.management.profile.AzureProfile;
9+
import com.azure.identity.DefaultAzureCredentialBuilder;
10+
11+
/**
12+
* WARNING: MODIFYING THIS FILE WILL REQUIRE CORRESPONDING UPDATES TO README.md FILE. LINE NUMBERS
13+
* ARE USED TO EXTRACT APPROPRIATE CODE SEGMENTS FROM THIS FILE. ADD NEW CODE AT THE BOTTOM TO AVOID CHANGING
14+
* LINE NUMBERS OF EXISTING CODE SAMPLES.
15+
*
16+
* Code samples for the README.md
17+
*/
18+
public class ReadmeSamples {
19+
20+
public void authenticate() {
21+
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
22+
TokenCredential credential = new DefaultAzureCredentialBuilder()
23+
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
24+
.build();
25+
AppServiceManager manager = AppServiceManager
26+
.authenticate(credential, profile);
27+
}
28+
}

0 commit comments

Comments
 (0)