shilang 发表于 2017-6-30 10:54:25

CentOS 7.2 PowerShell下安装Azure Module

  目前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
页: [1]
查看完整版本: CentOS 7.2 PowerShell下安装Azure Module