LoginSignup
1
1

More than 5 years have passed since last update.

Azure Resource Manager(ARM)の小ネタ:Marketplaceのサードパーティー製品をJSONテンプレートからデプロイ

Last updated at Posted at 2017-01-06

はじめに

やっと私にも「Infrastructure as code」の波が押し寄せてきたので、Azure Resource Manager(ARM)の小ネタを投稿します。

無料Linux、有料Linux

Azure MarketplaceにはLinuxの各種ディストリビューションがありますが、無料のもの(Azure代はかかりますが)と有料のものがあります。

【無料のものの例】
- CentOS
- Ubuntu

【有料のものの例】
- Red Hat Enterprise Linux
- Asianux

例えばAsianux Server7 SP1はAzure費用の他に0.7円/時の費用が追加でかかります。
こちらの費用はAzure費用と一緒に請求されずに別請求となります。
image

仮想マシンデプロイ方法

Azureポータル画面から仮想マシンを作成する場合は上記の購入ブレードから料金を確認後「購入」を押せば仮想マシンが作成され、課金も始まります。

ただしこちらをJSONテンプレートを使ってデプロイをすると、合っているはずのテンプレートファイルであるのに、エラーが出力されます。

PS C:\> New-AzureRmResourceGroupDeployment -ResourceGroupName TESTRG -TemplateParameterFile .\vm-parameters.json -TemplateFile .\vm-template-asianux.json
New-AzureRmResourceGroupDeployment : 9:44:51 - Resource Microsoft.Compute/virtualMachines 'TESTVM01' failed with messa
ge '{
  "error": {
    "code": "ResourcePurchaseValidationFailed",
    "message": "User failed validation to purchase resources. Error message: 'Legal terms have not been accepted for this item on this subscription. To accept legal terms, please go to the Azure portal (http://go.microsoft.com/fwlink/?LinkId=534873) and configure programmatic deployment for the Marketplace item or create it there for the first time'"
  }
}'
発生場所 行:1 文字:1
+ New-AzureRmResourceGroupDeployment -ResourceGroupName TESTRG -Templat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDe 
   ploymentCmdlet

(以下略)

要するに「お金が別途かかる仮想マシンだから、許諾とかチェックしてね」的なことが書いてあります(ホントか?)

対処方法ですが、事前にAzureポータル画面のマーケットプレイスから該当する製品の情報を表示して、そちらのブレード下部にある「プログラムによるデプロイについて」をクリックします。
image

続けて開いた「プログラムによるデプロイの構成」ブレードの下部に現在有効なサブスクリプションの一覧が出ていますので、JSONテンプレートからデプロイを行うサブスクリプションの状態を「有効化」に変更して「保存」をクリックします。
image

はい、今度はうまくいきました。

PS C:\> New-AzureRmResourceGroupDeployment -ResourceGroupName TESTRG -TemplateParameterFile .\vm-parameters.json -TemplateFile .\vm-template-asianux.json


DeploymentName          : vm-template-asianux
ResourceGroupName       : TESTRG
ProvisioningState       : Succeeded
Timestamp               : 2017/01/06 1:37:54
Mode                    : Incremental
TemplateLink            : 
Parameters              : 
                          Name             Type                       Value     
                          ===============  =========================  ==========
                          addressPrefix    String                     192.168.0.0/16
                          adminPassword    SecureString                         
                          adminUsername    String                     azureuser 
                          networkInterfaceName  String                     TESTVM-nic
                          networkSecurityGroupName1  String                     TEST-subnet1-nsg
                          publicIpAddressName  String                     TESTVM01-pip
                          storageAccountName  String                     ktkrtest20170106st01
                          storageAccountType  String                     Standard_LRS
                          subnetName1      String                     Subnet-1  
                          subnetPrefix1    String                     192.168.0.0/24
                          virtualMachineName  String                     TESTVM01  
                          virtualMachineSize  String                     Standard_F1s
                          virtualNetworkName  String                     TEST-vnet 

Outputs                 : 
DeploymentDebugLogLevel : 

image

OSにsshでログインして、ディストリビューションも確認します。
image

おわりに

Azure Resource Managerが出てすでに一年半以上経過しており、基本的なJSONテンプレートの使い方、作り方に関する情報もネット上に結構出てきたと思います。
その中でも私が「Infrastructure as code」を実践していくなかで、ネタになりそうなことがあれば今後も記事を公開していきたいと思います!

1
1
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
1
1