Skip to content

Commit 733c0fc

Browse files
committed
Release azure-resourcemanager 2.0.0
1 parent 61c6636 commit 733c0fc

File tree

4 files changed

+1645
-1397
lines changed

4 files changed

+1645
-1397
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-extension-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.ListVirtualMachineExtensionImages</mainClass>
18+
<mainClass>com.azure.resourcemanager.compute.samples.ListVirtualMachineExtensionImages</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.ListVirtualMachineExtensionImages.java</mainClass>
44+
<mainClass>com.azure.resourcemanager.compute.samples.ListVirtualMachineExtensionImages.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>
+30-26
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-
package com.microsoft.azure.management.compute.samples;
7-
8-
import com.microsoft.azure.management.Azure;
9-
import com.microsoft.azure.management.compute.VirtualMachineExtensionImage;
10-
import com.microsoft.azure.management.compute.VirtualMachineExtensionImageType;
11-
import com.microsoft.azure.management.compute.VirtualMachineExtensionImageVersion;
12-
import com.microsoft.azure.management.compute.VirtualMachinePublisher;
13-
import com.microsoft.azure.management.resources.fluentcore.arm.Region;
14-
import com.microsoft.rest.LogLevel;
15-
16-
import java.io.File;
17-
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.VirtualMachineExtensionImage;
13+
import com.azure.resourcemanager.compute.models.VirtualMachineExtensionImageType;
14+
import com.azure.resourcemanager.compute.models.VirtualMachineExtensionImageVersion;
15+
import com.azure.resourcemanager.compute.models.VirtualMachinePublisher;
16+
import com.azure.core.management.Region;
17+
import com.azure.core.management.profile.AzureProfile;
1818

1919
/**
2020
* List all virtual machine extension image publishers and
@@ -25,10 +25,10 @@ public final class ListVirtualMachineExtensionImages {
2525

2626
/**
2727
* Main function which runs the actual sample.
28-
* @param azure instance of the azure client
28+
* @param azureResourceManager instance of the azure client
2929
* @return true if sample runs successfully
3030
*/
31-
public static boolean runSample(Azure azure) {
31+
public static boolean runSample(AzureResourceManager azureResourceManager) {
3232
final Region region = Region.US_WEST_CENTRAL;
3333

3434
//=================================================================
@@ -37,7 +37,7 @@ public static boolean runSample(Azure azure) {
3737
// published by Microsoft.OSTCExtensions and Microsoft.Azure.Extensions
3838
// by browsing through extension image publishers, types, and versions
3939

40-
List<VirtualMachinePublisher> publishers = azure
40+
PagedIterable<VirtualMachinePublisher> publishers = azureResourceManager
4141
.virtualMachineImages()
4242
.publishers()
4343
.listByRegion(region);
@@ -90,14 +90,18 @@ public static void main(String[] args) {
9090
//=================================================================
9191
// Authenticate
9292

93-
final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));
93+
final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
94+
final TokenCredential credential = new DefaultAzureCredentialBuilder()
95+
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
96+
.build();
9497

95-
Azure azure = Azure.configure()
96-
.withLogLevel(LogLevel.NONE)
97-
.authenticate(credFile)
98-
.withDefaultSubscription();
98+
AzureResourceManager azureResourceManager = AzureResourceManager
99+
.configure()
100+
.withLogLevel(HttpLogDetailLevel.BASIC)
101+
.authenticate(credential, profile)
102+
.withDefaultSubscription();
99103

100-
runSample(azure);
104+
runSample(azureResourceManager);
101105
} catch (Exception e) {
102106
System.out.println(e.getMessage());
103107
e.printStackTrace();

0 commit comments

Comments
 (0)