简体   繁体   English

macOS 上的 Azure Az PowerShell 模块

[英]Azure Az PowerShell module on macOS

I am trying to work with some ARM templates in Azure and I am completing some Microsoft exercises dedicated to ARM templates.我正在尝试在 Azure 中使用一些 ARM 模板,并且正在完成一些专门针对 ARM 模板的 Microsoft 练习。 Even though I have Powershell installed on my mac(M1 air with os Monterey v12.4) I can not install the Azure Az PowerShell module and therefore cannot work with ARM templates like I would like to.即使我在我的 Mac 上安装了 Powershell(带有 os Monterey v12.4 的 M1 air),我也无法安装 Azure Az PowerShell 模块,因此无法像我想要的那样使用 ARM 模板。

My Powershell should work, at least from what I can see.我的 Powershell 应该可以工作,至少从我所看到的情况来看是这样。 When I use the command $PSversionTable I get this output:当我使用命令$PSversionTable我得到这个输出: Powershell版本说明

When I navigated to Microsoft documentation that is dedicated to installing this module ( https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-8.1.0 ) I concluded that I am okay with the requirements (I have PWSH 7.1.3+).当我导航到专门用于安装此模块的 Microsoft 文档 ( https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-8.1.0 ) 时,我得出的结论是,我可以满足要求(我有 PWSH 7.1.3+)。

When I executed the command Get-ExecutionPolicy -List I got this result:当我执行命令Get-ExecutionPolicy -List我得到了这个结果: 评分 ExecutionPolicy 输出

In this section, they also write that在本节中,他们还写道

PowerShell script execution policy must be set to remote signed or less restrictive PowerShell 脚本执行策略必须设置为远程签名或限制较少

which I guess I do have since I have Unrestricted everywhere.我想我确实有,因为我到处都是无限制的。 And also even if I wanted to set it to Remote signed I am not able to because if I execute this command Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser I get this output Set-ExecutionPolicy: Operation is not supported on this platform.而且即使我想将其设置为远程签名,我也无法这样做,因为如果我执行此命令Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser我会得到此输出Set-ExecutionPolicy: Operation is not supported on this platform.

So when I finally tried to install the module with this command from the MS website Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force I got this:因此,当我最终尝试从 MS 网站Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force使用此命令安装模块时,我得到了这个: 未找到匹配项以及模块列表

I have tried to figure out why I do have only one module listed there and also why I am not able to install the Az Powershell module but I was not able to find the answer.我试图弄清楚为什么我在那里只列出了一个模块,以及为什么我无法安装 Az Powershell 模块但我找不到答案。 Do you have any idea what could be wrong here?你知道这里有什么问题吗?

In your mac machine if you already have a .NET SDK you can follow the below steps to install the Az PowerShell Module在您的 mac 机器上,如果您已经有一个.NET SDK ,您可以按照以下步骤安装Az PowerShell模块

  • Install the dotnet core latest stable version in your Mac在 Mac 中安装dotnet core最新稳定版本

  • Install the PowerShell Core using below .NET command使用以下 .NET 命令安装 PowerShell Core

dotnet tool install --global PowerShell 

After installing the PowerShell core we can use the pwsh command安装 PowerShell 核心后,我们可以使用pwsh命令

  • Install Az PowerShell Module using below command使用以下命令安装 Az PowerShell 模块
Install-Module -Name Az -AllowClobber -Scope CurrentUser

IF you don't have the .NET SDK in your machine, you can refer this for more information如果您的机器中没有 .NET SDK,您可以参考这里获取更多信息

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

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