Skip to content

Commit 63db373

Browse files
authored
Merge pull request #85603 from nickzhums/patch-3
Update to latest Java SDK
2 parents c58ddac + d286896 commit 63db373

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

articles/app-service/overview-managed-identity.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -472,29 +472,34 @@ To learn more about configuring AzureServiceTokenProvider and the operations it
472472

473473
For Java applications and functions, the simplest way to work with a managed identity is through the [Azure SDK for Java](https://github.com/Azure/azure-sdk-for-java). This section shows you how to get started with the library in your code.
474474

475-
1. Add a reference to the [Azure SDK library](https://mvnrepository.com/artifact/com.microsoft.azure/azure). For Maven projects, you might add this snippet to the `dependencies` section of the project's POM file:
475+
1. Add a reference to the [Azure SDK library](https://mvnrepository.com/artifact/com.azure.resourcemanager/azure-resourcemanager). For Maven projects, you might add this snippet to the `dependencies` section of the project's POM file:
476476

477477
```xml
478478
<dependency>
479-
<groupId>com.microsoft.azure</groupId>
480-
<artifactId>azure</artifactId>
481-
<version>1.23.0</version>
479+
<groupId>com.azure.resourcemanager</groupId>
480+
<artifactId>azure-resourcemanager</artifactId>
481+
<version>2.10.0</version>
482482
</dependency>
483483
```
484484

485-
2. Use the `AppServiceMSICredentials` object for authentication. This example shows how this mechanism may be used for working with Azure Key Vault:
485+
2. Use the `ManagedIdentityCredential` object for authentication. This example shows how this mechanism may be used for working with Azure Key Vault:
486486

487487
```java
488-
import com.microsoft.azure.AzureEnvironment;
489-
import com.microsoft.azure.management.Azure;
490-
import com.microsoft.azure.management.keyvault.Vault
488+
import com.azure.core.management.AzureEnvironment;
489+
import com.azure.core.management.profile.AzureProfile;
490+
import com.azure.identity.ManagedIdentityCredential;
491+
import com.azure.identity.ManagedIdentityCredentialBuilder;
492+
import com.azure.resourcemanager.AzureResourceManager;
493+
import com.azure.resourcemanager.keyvault.models.Vault;
491494
//...
492-
Azure azure = Azure.authenticate(new AppServiceMSICredentials(AzureEnvironment.AZURE))
493-
.withSubscription(subscriptionId);
494-
Vault myKeyVault = azure.vaults().getByResourceGroup(resourceGroup, keyvaultName);
495+
AzureProfile azureProfile = new AzureProfile(AzureEnvironment.AZURE);
496+
ManagedIdentityCredential managedIdentityCredential = new ManagedIdentityCredentialBuilder().build();
497+
AzureResourceManager azure = AzureResourceManager.authenticate(managedIdentityCredential, azureProfile).withSubscription("subscription");
495498

496-
```
499+
Vault vault = azure.vaults().getByResourceGroup("resourceGroup", "keyVaultName");
497500

501+
```
502+
For more information on how to use the Azure SDK for Java, please refer to this [quickstart guide](https://aka.ms/azsdk/java/mgmt). To learn more about Azure Identiy and authentication and Managed Identity in general, please visit [this guide](https://github.com/Azure/azure-sdk-for-java/wiki/Azure-Identity-Examples#authenticating-a-user-assigned-managed-identity-with-defaultazurecredential)
498503

499504
## <a name="remove"></a>Remove an identity
500505

@@ -527,4 +532,4 @@ Update-AzFunctionApp -Name $functionAppName -ResourceGroupName $resourceGroupNam
527532
- [Call Microsoft Graph securely using a managed identity](scenario-secure-app-access-microsoft-graph-as-app.md)
528533
- [Connect securely to services with Key Vault secrets](tutorial-connect-msi-key-vault.md)
529534

530-
[Microsoft.Azure.Services.AppAuthentication reference]: /dotnet/api/overview/azure/service-to-service-authentication
535+
[Microsoft.Azure.Services.AppAuthentication reference]: /dotnet/api/overview/azure/service-to-service-authentication

0 commit comments

Comments
 (0)