目前Linux版本的PowerShell還是Alpha版本,所以很多功能不能使用。
比如通過Powershell命令:install-module AzureRM線上安裝Azure的Module。但我們可以通過變通的方式實現對Azure元件的安裝:
1. 如前文中所述,安裝PowerShell,或者在下載rpm安裝包後,用yum安裝:
yum install ./powershell-6.0.0_alpha.9-1.el7.centos.x86_64.rpm
2. 安裝完成後,建立PowerShell Moudle的安裝目錄:
mkdir -p /usr/local/share/powershell/Modules
3. 進入PowerShell環境:
powershell
4. 安裝Azure包:
Install-Package -Name AzureRM.NetCore.Preview -Source https://www.powershellgallery.com/api/v2 -ProviderName NuGet -ExcludeVersion -Destination /usr/local/share/powershell/Modules
5. Import Azure包:
Import-Module AzureRM.NetCore.Preview
下面就可以用Azure的命令進行登入,和管理Azure了:
Login-AzureRmAccount -EnvironmentName AzureChinaCloud VERBOSE: To sign in, use a web browser to open the page https://aka.ms/deviceloginchina. Enter the code xxxxxxxx to authenticate.
在PC上開啟瀏覽器,出入連結和code,進行使用者認證。認證後出現如下資訊: Environment : AzureChinaCloud Account : admin@xxxx.partner.onmschina.cn TenantId : xxxx SubscriptionId : xxxx SubscriptionName : weiheng1 CurrentStorageAccount :
通過PowerShell命令得到Azure的ResourceGroup資訊:
Get-AzureRmResourceGroup
ResourceGroupName : Default-Networking Location : chinaeast ProvisioningState : Succeeded Tags : ResourceId : /subscriptions/xxxx/resourceGroups/Default-Networking