powershell - Azure:使用 Cmdlet 更改 VM 名称

标签 powershell azure azure-storage azure-virtual-machine

我错误地命名了虚拟机。

使用 Azure Powershell,我可以使用 Set-AzureService 重命名云服务。似乎没有用于重命名虚拟机的 Set-AzureVM 命令。

还有其他方法可以重命名虚拟机吗?我不想更改虚拟机的服务名称。

编辑,进一步清晰:

我不想重命名虚拟机实例中的云服务名称或机器/计算机名称。我纯粹希望更改标记我的虚拟机的关联名称。即您在门户中看到的名称

带有红色箭头的列中的名称:

enter image description here

最佳答案

Set-AzureService 不更改服务名称!它仅更改部署名称描述。这些属性只是与托管服务部署关联的元数据。您无法以任何方式更改云服务名称(**cloudservice**.cloudapp.net)!您只能创建或删除云服务。

而且,您并非无法通过 Azure PowerShell cmdlet 更改 VM 的名称,但您很可能可以通过对目标 VM 的远程电源 shell 来执行此操作。请注意,重命名 Windows 计算机始终需要重新启动!

有关如何在 Azure VM 上使用远程 Power Shell 的信息,请查看 this article .

更新

我认为你需要的是UpdateRole对管理 API 的操作。它有参数RoleName,描述为:

RoleName
Required. Specifies the name for the virtual machine. The name must be unique within Windows Azure.

要使用的 powershell cmdlet 是:Update-AzureVM

关于powershell - Azure:使用 Cmdlet 更改 VM 名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17186719/

相关文章:

azure - 部署 MEAN 应用程序

azure - 如何删除 Azure 中租用的 blob?

Java-Azure 列表 Blob 目录

powershell - 电源外壳 : A command as a variable with parameter

powershell - 新的pnp站点的Powershell PnP命令出现错误

security - 来自辅助角色的 HTTP 与 HTTPS Azure 存储连接

Azure 表存储 - 501 未实现

powershell - 如何在 PowerShell 中将参数传递给调用表达式?

wpf - powershell:组合框仅显示System.Data.DataRowView

azure - 如何在部署时发送包含在 Azure DevOps 管道上完成的任务的电子邮件?