Skip to content

Commit d4ac901

Browse files
committed
Release azure-resourcemanager 2.0.0
1 parent 55896ed commit d4ac901

File tree

4 files changed

+1647
-1400
lines changed

4 files changed

+1647
-1400
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extensions:
2323

2424
To run this sample:
2525

26-
Set the environment variable `AZURE_AUTH_LOCATION` with the full path for an auth file. See [how to create an auth file](https://github.com/Azure/azure-libraries-for-java/blob/master/AUTH.md).
26+
See [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/identity/azure-identity#defaultazurecredential) and prepare the authentication works best for you. For more details on authentication, please refer to [AUTH.md](https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/AUTH.md).
2727

2828
git clone https://github.com/Azure-Samples/compute-java-list-compute-skus.git
2929

@@ -33,9 +33,11 @@ Set the environment variable `AZURE_AUTH_LOCATION` with the full path for an aut
3333

3434
## More information ##
3535

36-
[http://azure.com/java](http://azure.com/java)
36+
For general documentation as well as quickstarts on how to use Azure Management Libraries for Java, please see [here](https://aka.ms/azsdk/java/mgmt).
3737

38-
If you don't have a Microsoft Azure subscription you can get a FREE trial account [here](http://go.microsoft.com/fwlink/?LinkId=330212)
38+
Start to develop applications with Java on Azure [here](http://azure.com/java).
39+
40+
If you don't have a Microsoft Azure subscription you can get a FREE trial account [here](http://go.microsoft.com/fwlink/?LinkId=330212).
3941

4042
---
4143

pom.xml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
<artifactId>exec-maven-plugin</artifactId>
1616
<version>1.4.0</version>
1717
<configuration>
18-
<mainClass>com.microsoft.azure.management.compute.samples.ListComputeSkus</mainClass>
18+
<mainClass>com.azure.resourcemanager.compute.samples.ListComputeSkus</mainClass>
19+
<cleanupDaemonThreads>false</cleanupDaemonThreads>
1920
</configuration>
2021
</plugin>
2122
<plugin>
2223
<artifactId>maven-compiler-plugin</artifactId>
23-
<version>3.0</version>
24+
<version>3.8.1</version>
2425
<configuration>
25-
<source>1.7</source>
26-
<target>1.7</target>
26+
<source>1.8</source>
27+
<target>1.8</target>
2728
</configuration>
2829
</plugin>
2930
<plugin>
@@ -40,7 +41,7 @@
4041
</descriptorRefs>
4142
<archive>
4243
<manifest>
43-
<mainClass>com.microsoft.azure.management.compute.samples.ListComputeSkus.java</mainClass>
44+
<mainClass>com.azure.resourcemanager.compute.samples.ListComputeSkus.java</mainClass>
4445
</manifest>
4546
</archive>
4647
</configuration>
@@ -51,24 +52,19 @@
5152
</build>
5253
<dependencies>
5354
<dependency>
54-
<groupId>com.microsoft.azure</groupId>
55-
<artifactId>azure</artifactId>
56-
<version>1.36.3</version>
55+
<groupId>com.azure.resourcemanager</groupId>
56+
<artifactId>azure-resourcemanager</artifactId>
57+
<version>2.0.0</version>
5758
</dependency>
5859
<dependency>
59-
<groupId>commons-net</groupId>
60-
<artifactId>commons-net</artifactId>
61-
<version>3.3</version>
62-
</dependency>
63-
<dependency>
64-
<groupId>commons-lang</groupId>
65-
<artifactId>commons-lang</artifactId>
66-
<version>2.6</version>
60+
<groupId>com.azure</groupId>
61+
<artifactId>azure-identity</artifactId>
62+
<version>1.1.3</version>
6763
</dependency>
6864
<dependency>
69-
<groupId>org.apache.commons</groupId>
70-
<artifactId>commons-lang3</artifactId>
71-
<version>3.7</version>
65+
<groupId>commons-net</groupId>
66+
<artifactId>commons-net</artifactId>
67+
<version>3.6</version>
7268
</dependency>
7369
</dependencies>
7470
</project>

src/main/java/com/microsoft/azure/management/compute/samples/ListComputeSkus.java renamed to src/main/java/com/azure/resourcemanager/compute/samples/ListComputeSkus.java

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
/**
2-
* Copyright (c) Microsoft Corporation. All rights reserved.
3-
* Licensed under the MIT License. See License.txt in the project root for
4-
* license information.
5-
*/
6-
7-
package com.microsoft.azure.management.compute.samples;
8-
9-
import com.microsoft.azure.PagedList;
10-
import com.microsoft.azure.management.Azure;
11-
import com.microsoft.azure.management.compute.ComputeResourceType;
12-
import com.microsoft.azure.management.compute.ComputeSku;
13-
import com.microsoft.azure.management.resources.fluentcore.arm.AvailabilityZoneId;
14-
import com.microsoft.azure.management.resources.fluentcore.arm.Region;
15-
import com.microsoft.rest.LogLevel;
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.resourcemanager.compute.samples;
5+
6+
import com.azure.core.credential.TokenCredential;
7+
import com.azure.core.http.policy.HttpLogDetailLevel;
8+
import com.azure.core.http.rest.PagedIterable;
9+
import com.azure.core.management.AzureEnvironment;
10+
import com.azure.identity.DefaultAzureCredentialBuilder;
11+
import com.azure.resourcemanager.AzureResourceManager;
12+
import com.azure.resourcemanager.compute.models.ComputeResourceType;
13+
import com.azure.resourcemanager.compute.models.ComputeSku;
14+
import com.azure.resourcemanager.resources.fluentcore.arm.AvailabilityZoneId;
15+
import com.azure.core.management.Region;
16+
import com.azure.core.management.profile.AzureProfile;
1617

17-
import java.io.File;
1818
import java.util.Map;
1919
import java.util.Set;
2020

@@ -29,10 +29,10 @@ public final class ListComputeSkus {
2929

3030
/**
3131
* Main function which runs the actual sample.
32-
* @param azure instance of the azure client
32+
* @param azureResourceManager instance of the azure client
3333
* @return true if sample runs successfully
3434
*/
35-
public static boolean runSample(Azure azure) {
35+
public static boolean runSample(AzureResourceManager azureResourceManager) {
3636

3737
//=================================================================
3838
// List all compute SKUs in the subscription
@@ -43,7 +43,7 @@ public static boolean runSample(Azure azure) {
4343
System.out.println(String.format(format, "Name", "ResourceType", "Size", "Regions [zones]"));
4444
System.out.println("============================================================================");
4545

46-
PagedList<ComputeSku> skus = azure.computeSkus().list();
46+
PagedIterable<ComputeSku> skus = azureResourceManager.computeSkus().list();
4747
for (ComputeSku sku : skus) {
4848
String size = null;
4949
if (sku.resourceType().equals(ComputeResourceType.VIRTUALMACHINES)) {
@@ -55,7 +55,6 @@ public static boolean runSample(Azure azure) {
5555
} else if (sku.resourceType().equals(ComputeResourceType.SNAPSHOTS)) {
5656
size = sku.diskSkuType().toString();
5757
}
58-
Map<Region, Set<AvailabilityZoneId>> regionZones = sku.zones();
5958
System.out.println(String.format(format, sku.name(), sku.resourceType(), size, regionZoneToString(sku.zones())));
6059
}
6160

@@ -68,8 +67,8 @@ public static boolean runSample(Azure azure) {
6867
System.out.println(String.format(format, "Name", "Size", "Regions [zones]"));
6968
System.out.println("============================================================================");
7069

71-
skus = azure.computeSkus()
72-
.listbyRegionAndResourceType(Region.US_EAST2, ComputeResourceType.VIRTUALMACHINES);
70+
skus = azureResourceManager.computeSkus()
71+
.listByRegionAndResourceType(Region.US_EAST2, ComputeResourceType.VIRTUALMACHINES);
7372
for (ComputeSku sku : skus) {
7473
final String line = String.format(format, sku.name(), sku.virtualMachineSizeType(), regionZoneToString(sku.zones()));
7574
System.out.println(line);
@@ -84,7 +83,7 @@ public static boolean runSample(Azure azure) {
8483
System.out.println(String.format(format, "Name", "Size", "Regions [zones]"));
8584
System.out.println("============================================================================");
8685

87-
skus = azure.computeSkus()
86+
skus = azureResourceManager.computeSkus()
8887
.listByResourceType(ComputeResourceType.DISKS);
8988
for (ComputeSku sku : skus) {
9089
final String line = String.format(format, sku.name(), sku.diskSkuType(), regionZoneToString(sku.zones()));
@@ -117,14 +116,18 @@ public static void main(String[] args) {
117116
//=================================================================
118117
// Authenticate
119118

120-
final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));
119+
final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
120+
final TokenCredential credential = new DefaultAzureCredentialBuilder()
121+
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
122+
.build();
121123

122-
Azure azure = Azure.configure()
123-
.withLogLevel(LogLevel.NONE)
124-
.authenticate(credFile)
125-
.withDefaultSubscription();
124+
AzureResourceManager azureResourceManager = AzureResourceManager
125+
.configure()
126+
.withLogLevel(HttpLogDetailLevel.BASIC)
127+
.authenticate(credential, profile)
128+
.withDefaultSubscription();
126129

127-
runSample(azure);
130+
runSample(azureResourceManager);
128131
} catch (Exception e) {
129132
System.out.println(e.getMessage());
130133
e.printStackTrace();

0 commit comments

Comments
 (0)