繁体   English   中英

使用CLI将Azure VM从一个OMS工作区移动到另一个

[英]Move Azure VM from one OMS work-space to another using CLI

是否存在将Azure VM从一个OMS(Log Analytics)工作区移动到另一个OMS工作区的命令?

我阅读了AzureRmResource的文档,但不确定这是否是正确的选择?

使用命令“ az vm扩展集”。

示例bash脚本。

#!/bin/sh

vmname=<Replace with your vm name>
rgname=<Replace with your Resource Group name>
omsid=<Replace with your OMS Id>
omskey=<Replace with your OMS key>

az vm extension set \
  --resource-group $rgname \
  --vm-name $vmname \
  --name OmsAgentForLinux \
  --publisher Microsoft.EnterpriseCloud.Monitoring \
  --version 1.0 --protected-settings '{"workspaceKey": "'"$omskey"'"}' \
  --settings '{"workspaceId": "'"$omsid"'"}'

根据您的情况,您需要在VM上删除代理,并使用新的OMS配置安装OMS代理。 这是您可以使用的脚本。 我在实验室测试,对我有用。

#!/bin/sh

# resource group name, vm nmae, OMS Id and OMS key.
rg=<resource group name>
vmname=<>
omsid="<>"
omskey=""

##Remvoe OMS agent from VM
az vm extension delete -g $rg --vm-name $vmname -n OmsAgentForLinux

# re-install and configure the OMS agent with your new OMS.
az vm extension set \
  --resource-group $rg \
  --vm-name $vmname \
  --name OmsAgentForLinux \
  --publisher Microsoft.EnterpriseCloud.Monitoring \
  --version 1.0 --protected-settings '{"workspaceKey": "'"$omskey"'"}' \
  --settings '{"workspaceId": "'"$omsid"'"}'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM