我正在尝试从 AzureRM 升级到适用于 powershell 的新 Az 模块。我们仍然有多种使用“旧版”服务管理 API 资源的情况,例如经典的 Azure 云服务,并且这些(据我所知)仍然需要使用旧的 Azure powershell 模块。
我已卸载所有 AzureRM 模块,然后安装新的 Az 模块。但这样做似乎会破坏旧版 Azure 模块。看来Azure模块和AzureRM之间存在依赖关系。运行任何服务管理命令(例如“Get-AzureService”)会产生以下结果:
PS C:\WINDOWS\system32> Get-AzureService
Get-AzureService : Exception has been thrown by the target of an invocation.
At line:1 char:1
+ Get-AzureService
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureService], TargetInvocationException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.GetAzureServiceCommand
我尝试更新到最新的 Azure powershell 模块 (Update-Module Azure)。这似乎还安装了 AzureRM.profile。
由于该模块无法与 Az 模块同时安装/使用,因此我不知道如何继续。
如果您还想使用新的 Az 模块,是否无法通过 powershell 使用旧版服务管理 API?
最佳答案
Az 模块具有兼容模式,可帮助您在更新到新语法时使用现有脚本。尝试运行Enable-AzureRmAlias在您想要在新的 Az session 中运行 AzureRM 命令之前,cmdlet 会启用兼容模式。
您可以通过 migrating existing scripts to Az 获取更多详细信息
关于azure - Az/AzureRM/旧版 Azure Powershell 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56380450/