Azure RM模块在MACOSX Catalina上不起作用

时间:2020-03-08 10:02:04

标签: macos powershell azure-rm az

我试图在OSXCatalina的Powershell核心上使用AzureRM和AZ模块,但是,当我尝试使用cmdlet Login-AzureRmAccount或Login-AzAccount时。我收到以下错误消息。 我目前正在使用Powershell版本7

Login-AzureRmAccount:术语“ Login-AzureRmAccount”未被识别为cmdlet,函数,脚本文件或可运行程序的名称。 检查名称的拼写,或者是否包含路径,请验证路径是否正确,然后重试。

Login-AzAccount:在模块“ Az.Accounts”中找到“ Login-AzAccount”命令,但是无法加载该模块。有关更多信息,请运行“导入模块Az.Accounts”。

1 个答案:

答案 0 :(得分:1)

这不是Powershell代码问题,这是我们在此提供的帮助。您的问题是环境问题,因此实际上应该将其移至SuperUser或StackExchange。

但是,由于您在这里,而且由于您可能尚未正确/完整地设置它,因此这是环境问题。如何设置和使用它的方法已在MS Docs,MSDN和其他许多位置上进行了全面记录。网络。快速搜索(例如使用'AzureRM osx')将显示以下内容。这些:

PowerShell, Azure and macOS? Absolutely!

借助macOS上的Azure CLI,您可以做一些有趣的事情,例如 供应新的VM或获取有关它们的状态概述。但是Azure CLI 不是PowerShell,因此缺少一些我非常感谢的功能。

要通过以下方法管理Azure,需要执行几个步骤 Mac上的PowerShell:

Install PowerShell
Install .NET Core
Install the AzureRm.NetCore.Preview module

brew update
brew install openssl
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/

之后,您可以下载.NET Core的官方安装程序,用于 苹果系统。安装后,您需要初始化一些代码。你可以做 通过使用以下命令:

mkdir hwapp
cd hwapp
dotnet new
dotnet restore
dotnet run

Install-Package -Name AzureRM.NetCore.Preview -Source https://www.powershellgallery.com/api/v2 -ProviderName NuGet -ExcludeVersion -Destination /usr/local/microsoft/powershell/6.0.0-alpha.11/Modules

get-module -listAvailable

AzureRM PowerShell Mac OS X

通过在此处安装AzureRM可以解决所有问题:

Install-Package -Name AzureRM.NetCore.Preview -Source https://www.powershellgallery.com/api/v2/ -ProviderName NuGet -ExcludeVersion -Destination $home/powershell/modules

Import-Module $home/powershell/modules/AzureRM.Profile.NetCore.Preview
Import-Module $home/powershell/modules/AzureRM.Resources.NetCore.Preview
Import-Module $home/powershell/modules/AzureRM.NetCore.Preview
Login-AzureRmAccount

PS。每次重新启动PowerShell时,都必须重新运行Import-Module。

Powershell and Azure on MacOS

好吧,除非您将其放在个人资料中。

相关问题