使用 Azure SDK 为 VM 配置具有 Azure 资源托管标识Configure a VM with managed identities for Azure resources using an Azure SDK

Azure 资源的托管标识是 Azure Active Directory 的一项功能。Managed identities for Azure resources is a feature of Azure Active Directory. 支持 Azure 资源的托管标识的每个 Azure 服务都受其自己的时间线限制。Each of the Azure services that support managed identities for Azure resources are subject to their own timeline. 在开始之前,请务必查看资源的托管标识的可用性状态以及已知问题Make sure you review the availability status of managed identities for your resource and known issues before you begin.

Azure 资源的托管标识在 Azure Active Directory (AD) 中为 Azure 服务提供了一个自动托管标识。Managed identities for Azure resources provides Azure services with an automatically managed identity in Azure Active Directory (AD). 此标识可用于通过支持 Azure AD 身份验证的任何服务的身份验证,这样就无需在代码中插入凭据了。You can use this identity to authenticate to any service that supports Azure AD authentication, without having credentials in your code.

本文介绍如何使用 Azure SDK 为 Azure VM 启用和删除 Azure 资源托管标识。In this article, you learn how to enable and remove managed identities for Azure resources for an Azure VM, using an Azure SDK.

先决条件Prerequisites

  • 如果不熟悉 Azure 资源功能的托管标识,请参阅此概述If you're not familiar with the managed identities for Azure resources feature, see this overview.

Azure SDK 包含 Azure 资源托管标识支持Azure SDKs with managed identities for Azure resources support

Azure 通过一系列 Azure SDK 支持多个编程平台。Azure supports multiple programming platforms through a series of Azure SDKs. 其中多个平台已更新为支持 Azure 资源托管标识,并提供相应的示例来演示用法。Several of them have been updated to support managed identities for Azure resources, and provide corresponding samples to demonstrate usage. 由于添加了其他支持,此列表已更新:This list is updated as additional support is added:

SDKSDK 示例Sample
.NET.NET 从具有已启用的 Azure 资源托管标识的已启用的 VM 中管理资源Manage resource from a VM enabled with managed identities for Azure resources enabled
JavaJava 从具有 Azure 资源托管标识的已启用的 VM 中管理存储Manage storage from a VM enabled with managed identities for Azure resources
Node.jsNode.js 创建启用了系统分配托管标识的 VMCreate a VM with system-assigned managed identity enabled
PythonPython 创建启用了系统分配托管标识的 VMCreate a VM with system-assigned managed identity enabled
RubyRuby 创建启用了系统分配托管标识的 Azure VMCreate Azure VM with an system-assigned identity enabled

后续步骤Next steps

  • 请参阅“为 Azure VM 配置标识”下的相关文章,了解还可以如何使用 Azure 门户、PowerShell、CLI 和资源模板完成此操作 。See related articles under Configure Identity for an Azure VM, to learn how you can also use the Azure portal, PowerShell, CLI, and resource templates.