能够在不启用任何托管身份(系统或用户)的情况下安装Azure监视器代理安装

问题描述 投票:0回答:1

我可以安装 Azure 监视器代理安装,而无需通过下面的 powershell cmdlet 在虚拟机上启用任何托管标识(系统或用户)

系统分配:

 Set-AzVMExtension -Name AzureMonitorWindowsAgent -ExtensionType AzureMonitorWindowsAgent -Publisher Microsoft.Azure.Monitor -ResourceGroupName <resource-group-name> -VMName <virtual-machine-name> -Location <location> -TypeHandlerVersion <version-number> -EnableAutomaticUpgrade $true -SettingString '{"authentication":{"managedIdentity":{"identifier-name":"mi_res_id","identifier-value":"/subscriptions/<my-subscription-id>/resourceGroups/<my-resource-group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<my-user-assigned-identity>"}}}'

用户分配:

 Set-AzVMExtension -Name AzureMonitorWindowsAgent -ExtensionType AzureMonitorWindowsAgent -Publisher Microsoft.Azure.Monitor -ResourceGroupName <resource-group-name> -VMName <virtual-machine-name> -Location <location> -TypeHandlerVersion <version-number> -EnableAutomaticUpgrade $true


我在一组虚拟机上使用了上述两个 powershell cmdlet,并且没有分配任何系统或用户分配的托管身份,但如果我运行 power shell 脚本,我仍然可以安装代理,并且身份部分中没有反映任何更改虚拟机的。 如果我方向错误,有人可以帮助我理解 AMA 安装过程吗?

我使用以下文档构建了 powershell 脚本 https://learn.microsoft.com/en-us/azure/azure-monitor/agents/azure-monitor-agent-manage?tabs=azure-portal

azure virtual-machine azure-monitoring azure-vm-extension
1个回答
0
投票

能够在不启用任何托管身份(系统或用户)的情况下安装Azure监视器代理安装

如果您能够在未启用

系统管理身份
用户管理身份的情况下安装Azure Monitor Agent,可能是因为您使用的是用户帐户登录,而不是身份验证。

Set-AzVMExtension
命令也适用于用户身份验证。

在您的情况下,请确保在执行 Set-AzVMExtension 命令之前使用 Get-AzContext 检查您是否已使用用户帐户登录。

enter image description here

要使用身份登录以在虚拟机上安装代理,您需要在虚拟机内部启用该身份,分配虚拟机贡献者Azure连接的计算机资源管理员的角色,然后使用该身份登录下面的命令

使用托管身份进行连接,请参阅此链接以通过

VM

中的托管身份进行身份验证
Connect-AzAccount  -Identity
Set-AzContext -Subscription Subscription1

使用用户管理身份进行连接请参阅此链接以通过虚拟机中的用户管理身份进行身份验证。

Connect-AzAccount -Identity -AccountId  $identity.ClientId

就我而言,我安装了代理,但没有在

VM
中启用身份,并使用用户身份验证进行安装。

Set-AzVMExtension -Name AzureMonitorWindowsAgent -ExtensionType AzureMonitorWindowsAgent -Publisher Microsoft.Azure.Monitor -ResourceGroupName Venkat -VMName venkatvm -Location "East US" -TypeHandlerVersion "1.1" -EnableAutomaticUpgrade $true

输出:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.