Skip to content

Commit c095f55

Browse files
committed
Release azure-resourcemanager 2.0.0
1 parent b81641c commit c095f55

File tree

4 files changed

+1646
-1399
lines changed

4 files changed

+1646
-1399
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extensions:
2121

2222
To run this sample:
2323

24-
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).
24+
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).
2525

2626
git clone https://github.com/Azure-Samples/compute-java-list-vm-images.git
2727

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

3232
## More information ##
3333

34-
[http://azure.com/java](http://azure.com/java)
34+
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).
3535

36-
If you don't have a Microsoft Azure subscription you can get a FREE trial account [here](http://go.microsoft.com/fwlink/?LinkId=330212)
36+
Start to develop applications with Java on Azure [here](http://azure.com/java).
37+
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).
3739

3840
---
3941

pom.xml

+15-19
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.ListVirtualMachineImages</mainClass>
18+
<mainClass>com.azure.resourcemanager.compute.samples.ListVirtualMachineImages</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.ListVirtualMachineImages.java</mainClass>
44+
<mainClass>com.azure.resourcemanager.compute.samples.ListVirtualMachineImages.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/ListVirtualMachineImages.java renamed to src/main/java/com/azure/resourcemanager/compute/samples/ListVirtualMachineImages.java

+31-28
Original file line numberDiff line numberDiff line change
@@ -1,21 +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.management.Azure;
10-
import com.microsoft.azure.management.compute.VirtualMachineImage;
11-
import com.microsoft.azure.management.compute.VirtualMachineOffer;
12-
import com.microsoft.azure.management.compute.VirtualMachinePublisher;
13-
import com.microsoft.azure.management.compute.VirtualMachineSku;
14-
import com.microsoft.azure.management.resources.fluentcore.arm.Region;
15-
import com.microsoft.rest.LogLevel;
16-
17-
import java.io.File;
18-
import java.util.List;
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.VirtualMachineImage;
13+
import com.azure.resourcemanager.compute.models.VirtualMachineOffer;
14+
import com.azure.resourcemanager.compute.models.VirtualMachinePublisher;
15+
import com.azure.resourcemanager.compute.models.VirtualMachineSku;
16+
import com.azure.core.management.Region;
17+
import com.azure.core.management.profile.AzureProfile;
1918

2019
/**
2120
* List all virtual machine image publishers and
@@ -26,10 +25,10 @@ public final class ListVirtualMachineImages {
2625

2726
/**
2827
* Main function which runs the actual sample.
29-
* @param azure instance of the azure client
28+
* @param azureResourceManager instance of the azure client
3029
* @return true if sample runs successfully
3130
*/
32-
public static boolean runSample(Azure azure) {
31+
public static boolean runSample(AzureResourceManager azureResourceManager) {
3332
final Region region = Region.US_WEST_CENTRAL;
3433

3534
//=================================================================
@@ -38,7 +37,7 @@ public static boolean runSample(Azure azure) {
3837
// published by Canonical, Red Hat and SUSE
3938
// by browsing through locations, publishers, offers, SKUs and images
4039

41-
List<VirtualMachinePublisher> publishers = azure
40+
PagedIterable<VirtualMachinePublisher> publishers = azureResourceManager
4241
.virtualMachineImages()
4342
.publishers()
4443
.listByRegion(region);
@@ -94,14 +93,18 @@ public static void main(String[] args) {
9493
//=================================================================
9594
// Authenticate
9695

97-
final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));
96+
final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
97+
final TokenCredential credential = new DefaultAzureCredentialBuilder()
98+
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
99+
.build();
98100

99-
Azure azure = Azure.configure()
100-
.withLogLevel(LogLevel.NONE)
101-
.authenticate(credFile)
102-
.withDefaultSubscription();
101+
AzureResourceManager azureResourceManager = AzureResourceManager
102+
.configure()
103+
.withLogLevel(HttpLogDetailLevel.BASIC)
104+
.authenticate(credential, profile)
105+
.withDefaultSubscription();
103106

104-
runSample(azure);
107+
runSample(azureResourceManager);
105108
} catch (Exception e) {
106109
System.out.println(e.getMessage());
107110
e.printStackTrace();
@@ -110,4 +113,4 @@ public static void main(String[] args) {
110113

111114
private ListVirtualMachineImages() {
112115
}
113-
}
116+
}

0 commit comments

Comments
 (0)