azure - Az/AzureRM/旧版 Azure Powershell 冲突

标签 azure powershell azure-rm az

我正在尝试从 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。

AzureRm.profile dependency

由于该模块无法与 Az 模块同时安装/使用,因此我不知道如何继续。

Az and AzureRM conflict

如果您还想使用新的 Az 模块,是否无法通过 powershell 使用旧版服务管理 API?

最佳答案

Az 模块具有兼容模式,可帮助您在更新到新语法时使用现有脚本。尝试运行Enable-AzureRmAlias在您想要在新的 Az session 中运行 AzureRM 命令之前,cmdlet 会启用兼容模式。

enter image description here

您可以通过 migrating existing scripts to Az 获取更多详细信息

关于azure - Az/AzureRM/旧版 Azure Powershell 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56380450/

相关文章:

azure 计费费率卡 API 返回注释

azure - azure 上的 Windows 服务相当于什么?

azure - 无法连接到 Microsoft Azure 中的 Linux VM

电源外壳 |从 CSV 文件名列表中复制项目,登录到同一 CSV

powershell - 如何在PowerShell中创建匿名对象?

azure - 如何解决使用 Terraform 创建计划的 Sentinel 警报规则失败的问题

azure - 从付费 Azure SQL 数据库恢复为免费

powershell - 从许可证阵列中删除重复项

azure - 如何使用 Terraform 批准 Blob 存储 ADLS Gen2 上的托管专用端点?

azure - 无法使用 VS2022 部署通过 Terraform 创建的 Azure 容器应用程序