LoginSignup
2
4

More than 5 years have passed since last update.

Az PowerShellを使ってみました(1)

Posted at

経緯

これまでは以下からmsiをダウンロードしてインストールしていたのですが、Az PowerShellではリリースされないようなので、これを機にパッケージマネージャーを使ってインストールしてみることにしました。

環境

インストール

Powershellを起動して、以下のコマンドを実行します。

PS > Install-Module -Name Az -AllowClobber -Scope CurrentUser
信頼されていないリポジトリ
信頼されていないリポジトリからモジュールをインストールしようとしています。このリポジトリを信頼する場合は、Set-PSReposit
ory コマンドレットを実行して、リポジトリの InstallationPolicy の値を変更してください。'PSGallery'
からモジュールをインストールしますか?
[Y] はい(Y)  [A] すべて続行(A)  [N] いいえ(N)  [L] すべて無視(L)  [S] 中断(S)  [?] ヘルプ (既定値は "N"): Y

サインイン

PS > Connect-AzAccount
警告: To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code xxxxxxxxx to
authenticate.

以降、ブラウザからデバイスログインになります。Azure CLIっぽいですね。

バージョン確認

PS > Get-Module -Name Az*

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.0      Az.Accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Conn...
Script     1.0.0      Az.Compute                          {Add-AzContainerServiceAgentPoolProfile, Add-AzImageDataDi...
Script     1.0.0      Az.Resources                        {Add-AzADGroupMember, Export-AzResourceGroup, Get-AzADAppC...

スクリプト移行

以下のようにエイリアスコマンドを使用するか、"AzureRm"を"Az"に置換すればよさそうです。

PS > Enable-AzureRmAlias
PS > Get-AzureRmVm

ResourceGroupName  Name  Location          VmSize  OsType           NIC
-----------------  ----  --------          ------  ------           ---
xxxxxxxxxxx       xxxxx japaneast Standard_DS2_v2 Windows xxxxxxxxxxNIC

まとめと次回予告

これまでにAzure PowerShellをインストールしたことのない自宅のPCだったため、何の問題もなくセットアップできました。

(2)で既存のスクリプトを移行したいと思います。

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4