SlideShare a Scribd company logo
Customazed CLI:
カスタムVMイメージ作成支援ツール
2020-12-16 第30回 Tokyo Jazug Night (Online)
八重樫 剛史 Takeshi Yaegashi
自己紹介
2
八重樫 剛史 Takeshi Yaegashi
株式会社バンダイナムコスタジオ所属
Linux・Unix・OSS・Go 言語が好きなエンジニア
組み込みシステム開発、ゲームサーバ開発、CI/CD インフラ開発、
開発環境のクラウドシフトなどの業務に従事
活動場所
ホームページ・ブログ https://l0w.dev
GitHub https://github.com/yaegashi
GitLab https://gitlab.com/yaegashi
Twitter https://twitter.com/hogegashi
今日の話題 - Customazed CLI
3
https://github.com/yaegashi/customazed
▪ CustomAZed: Customized + Azure な造語
よみ:かすためいずど?
▪ ファイルのアップロードが必要になる
Azure リソース作りを支援してくれる CLI ツール
▪ Windows / macOS / Linux で動く (powered by Go)
▪ Qiita の紹介記事
Azure Advent Calendar 2020 14日目
https://qiita.com/yaegashi/items/5216a9b37c2041b93a3a
こういうのでイラッとした経験ないですか?
4
ARM Template などで頻出する VM CustomScript Extension のリソース
実行するスクリプトを非公開 Blob ストレージに置いて SAS つき URL を渡している
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.8",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"[uri(parameters('_artifactsLocation'), concat(variables('ScriptFileName'), parameters('_art
ifactsLocationSasToken')))]"
],
"commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -File ', variables('Scr
iptFolder'), '/', variables('ScriptFileName'))]"
}
}
こういうのでイラッとした経験ないですか?
5
Azure Image Builder のカスタマイザでも外部ファイル参照は出てくる
公開可能なファイルであれば GitHub に置くのでもよいが…
"customize": [
{
"type": "PowerShell",
"name": "CreateBuildPath",
"runElevated": false,
"scriptUri": "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/testPs
Script.ps1"
},
{
"type": "File",
"name": "downloadBuildArtifacts",
"sourceUri": "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickq
uickstarts/exampleArtifacts/buildArtifacts/index.html",
"destination": "c:¥¥buildArtifacts¥¥index.html"
},
いま編集中のファイルを持っていってほしい!
6
Customazed CLI を使えば楽になります!
7
{{upload `script/hello.ps1`}} のように書くと、ファイルを適切なストレージ
アカウントにアップロードした上で、ダウンロード URL を埋め込んでくれます
{
"fileUris": [
"{{upload `scripts/hello.ps1`}}"
],
"commandToExecute": "powershell -ExecutionPolicy Bypass -Command {{prefix}}/scripts/hello.ps1"
}
{
"fileUris": [
"https://customazed12345.blob.core.windows.net/customazed/9a85b47c-2e6e-508f-9c80-9dc6fb2d15
f3/scripts/hello.ps1"
],
"commandToExecute": "powershell -ExecutionPolicy Bypass -Command 9a85b47c-2e6e-508f-9c80-9dc6f
b2d15f3/scripts/hello.ps1"
}
Customazed CLI Example: CustomScript Extension
8
設定ファイル customazed.json を用意します (Go Template 記法)
{
"tenantId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"subscriptionId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"storage": {
"location": "westus2",
"resourceGroup": "CustomazedRG",
"accountName": "customazed12345",
"containerName": "customazed",
"prefix": "{{hash (cfg `machine.resourceGroup`) (cfg `machine.machineName`)}}"
},
"machine": {
"resourceGroup": "MachineRG",
"machineName": "windowsMachine"
}
}
Customazed CLI Example: CustomScript Extension
9
同じ場所に customazed_machine.json と scripts/hello.ps1 を用意します
{
"fileUris": [
"{{upload `scripts/hello.ps1`}}"
],
"commandToExecute": "powershell -ExecutionPolicy Bypass -Command {{prefix}}/scripts/hello.ps1"
}
Write-Host "hello, world"
Customazed CLI Example: CustomScript Extension
10
最初に認証を行い、機能・プロバイダの登録を行います (一度だけ必要)
$ customazed login
2020/12/16 16:40:02 Loading config file customazed.json
2020/12/16 16:40:02 To sign in, use a web browser to open the page https://microsoft.com/devic
elogin and enter the code HN54K2H9F to authenticate.
2020/12/16 16:41:04 Saving auth-dev token in .customazed/auth_dev.json
$ customazed feature register
2020/12/16 16:42:06 Loading config file customazed.json
2020/12/16 16:42:06 Loading auth-dev token in .customazed/auth_dev.json
2020/12/16 16:42:06 Feature: registering Microsoft.VirtualMachineImages/VirtualMachineTemplate
Preview
2020/12/16 16:42:09 Provider: registering Microsoft.VirtualMachineImages
2020/12/16 16:42:11 Provider: registering Microsoft.KeyVault
2020/12/16 16:42:13 Provider: registering Microsoft.Compute
2020/12/16 16:42:14 Provider: registering Microsoft.Storage
Customazed CLI Example: CustomScript Extension
11
ストレージアカウントの作成と必要なアクセス権限設定をしてくれます
$ customazed setup
2020/12/16 16:44:05 Loading config file customazed.json
2020/12/16 16:44:05 Loading auth-dev token in .customazed/auth_dev.json
2020/12/16 16:44:05 Loading auth-dev token in .customazed/auth_dev.json
2020/12/16 16:44:05 Storage: creating resource group: CustomazedRG
2020/12/16 16:44:08 Storage: creating storage account: customazed12345
2020/12/16 16:44:10 Storage: creating blob container: customazed
2020/12/16 16:44:10 Identity: missing configuration
2020/12/16 16:44:10 Machine: enabling system assigned identity
2020/12/16 16:45:12 Image: missing configuration
2020/12/16 16:45:12 Gallery: missing configuration
2020/12/16 16:45:12 Builder: missing configuration
2020/12/16 16:45:12 Identity: missing configuration
2020/12/16 16:45:12 Image: missing configuration
2020/12/16 16:45:12 Gallery: missing configuration
2020/12/16 16:45:12 Role: assign role to user for blob container
2020/12/16 16:45:14 Role: assign role to machine for blob container
Customazed CLI Example: CustomScript Extension
12
実行すると処理された customazed_machine.json を表示して確認待ちになります
$ customazed machine run
2020/12/16 16:47:11 Loading config file customazed.json
2020/12/16 16:47:11 Loading auth-dev token in .customazed/auth_dev.json
2020/12/16 16:47:11 Loading custom script settings customazed_machine.json
2020/12/16 16:47:11 Blob: adding scripts/hello.ps1
2020/12/16 16:47:11
{
"fileUris": [
"https://customazed12345.blob.core.windows.net/customazed/9a85b47c-2e6e-508f-9c80-9dc6f
b2d15f3/scripts/hello.ps1"
],
"commandToExecute": "powershell -ExecutionPolicy Bypass -Command 9a85b47c-2e6e-508f-9c80-
9dc6fb2d15f3/scripts/hello.ps1",
"timestamp": 1608104831
}
2020/12/16 16:47:11 Files to upload: 1
Press ENTER to proceed:
Customazed CLI Example: CustomScript Extension
13
実行完了後、出力結果を確認します
Press ENTER to proceed: (ENTER 押した)
2020/12/16 16:47:27 Loading auth-dev token in .customazed/auth_dev.json
2020/12/16 16:47:28 Blob: destination https://customazed12345.blob.core.windows.net/custom
azed/9a85b47c-2e6e-508f-9c80-9dc6fb2d15f3
2020/12/16 16:47:28 Blob: uploading scripts/hello.ps1
2020/12/16 16:47:30 Executing VM extension...
2020/12/16 16:48:30 Success: use "customazed machine show-status" to see the output
$ customazed machine show-status
2020/12/16 16:50:41 Loading config file customazed.json
2020/12/16 16:50:41 Loading auth-dev token in .customazed/auth_dev.json
2020/12/16 16:50:41 ProvisioningState/succeeded: Provisioning succeeded
Command execution finished
2020/12/16 16:50:41 StdOut:
hello, world
2020/12/16 16:50:41 StdErr:
Customazed CLI にできること (v0.3.1)
14
▪ Azure VM CustomScript Extension のサポート(この資料で解説)
− 手元にあるファイルを VM に送り込み、コマンド実行と結果取得が手軽にできる
− Windows Linux 両方の VM に対応
▪ Azure Image Builder のサポート(Qiita 記事で解説)
− AIB に必要なユーザー割り当て ID や共有イメージギャラリーなども自動的に作ってくれる
− Windows Virtual Desktop 向け VM イメージカスタマイズの CI/CD に活用
▪ 任意テキストの処理と、それに含まれるファイルのアップロード
− ARM Template などのプリプロセスに利用可能
Customazed CLI 今後の計画
15
▪ Azure VM RunCommand Extension サポート
− CustomScript とは異なる VM コマンド実行手段
▪ ARM Template サポート
− ARM Template を直接デプロイできる
− ARM TemplateSpec リソースを作成できる
▪ ZIP アップロード機能
− 複数のフォルダやファイルを自動的に ZIP ファイルにまとめてアップロード
▪ ドキュメントなどの充実
おわり
16
▪ ご清聴ありがとうございました

More Related Content

What's hot

Windows Azureで Webサーバーを再発明してみる
Windows AzureでWebサーバーを再発明してみるWindows AzureでWebサーバーを再発明してみる
Windows Azureで Webサーバーを再発明してみる
Sunao Tomita
 
Github codespaces すごく良い。もうこれで 十分なんじゃという話
Github codespaces すごく良い。もうこれで 十分なんじゃという話Github codespaces すごく良い。もうこれで 十分なんじゃという話
Github codespaces すごく良い。もうこれで 十分なんじゃという話
xiidec
 

What's hot (20)

一番簡単なWebSocketの試し方
一番簡単なWebSocketの試し方一番簡単なWebSocketの試し方
一番簡単なWebSocketの試し方
 
2020/06/16 tsjp-azure-staticwebapps-vs_codespaces
2020/06/16 tsjp-azure-staticwebapps-vs_codespaces2020/06/16 tsjp-azure-staticwebapps-vs_codespaces
2020/06/16 tsjp-azure-staticwebapps-vs_codespaces
 
Nuxt.js入門 2018/02/02 Vue.js入門勉強会@渋谷 発表資料
Nuxt.js入門 2018/02/02 Vue.js入門勉強会@渋谷 発表資料Nuxt.js入門 2018/02/02 Vue.js入門勉強会@渋谷 発表資料
Nuxt.js入門 2018/02/02 Vue.js入門勉強会@渋谷 発表資料
 
Windows Azureで Webサーバーを再発明してみる
Windows AzureでWebサーバーを再発明してみるWindows AzureでWebサーバーを再発明してみる
Windows Azureで Webサーバーを再発明してみる
 
Bicep + VS Code で楽々Azure Deploy
Bicep + VS Code で楽々Azure DeployBicep + VS Code で楽々Azure Deploy
Bicep + VS Code で楽々Azure Deploy
 
Rancher使ってみたよ(初心者向け)
Rancher使ってみたよ(初心者向け)Rancher使ってみたよ(初心者向け)
Rancher使ってみたよ(初心者向け)
 
はじめての CircleCI
はじめての CircleCIはじめての CircleCI
はじめての CircleCI
 
Github codespaces すごく良い。もうこれで 十分なんじゃという話
Github codespaces すごく良い。もうこれで 十分なんじゃという話Github codespaces すごく良い。もうこれで 十分なんじゃという話
Github codespaces すごく良い。もうこれで 十分なんじゃという話
 
VSCode Conference Japan 2021 kyusque
VSCode Conference Japan 2021 kyusqueVSCode Conference Japan 2021 kyusque
VSCode Conference Japan 2021 kyusque
 
dockerでImmutable InfrastructureなWordPressを考える
dockerでImmutable InfrastructureなWordPressを考えるdockerでImmutable InfrastructureなWordPressを考える
dockerでImmutable InfrastructureなWordPressを考える
 
Dockerで開発環境をデリバる
Dockerで開発環境をデリバるDockerで開発環境をデリバる
Dockerで開発環境をデリバる
 
PlayFramework 2.0 Javaと WebSocketでつくる リアルタイムMVC Webアプリケーション
PlayFramework 2.0 Javaと WebSocketでつくる リアルタイムMVC WebアプリケーションPlayFramework 2.0 Javaと WebSocketでつくる リアルタイムMVC Webアプリケーション
PlayFramework 2.0 Javaと WebSocketでつくる リアルタイムMVC Webアプリケーション
 
コンテナ事例 CircleCI, Cucumber-Chef
コンテナ事例 CircleCI, Cucumber-Chefコンテナ事例 CircleCI, Cucumber-Chef
コンテナ事例 CircleCI, Cucumber-Chef
 
kpackによるコンテナイメージのビルド
kpackによるコンテナイメージのビルドkpackによるコンテナイメージのビルド
kpackによるコンテナイメージのビルド
 
HTML5 Conference 2015 悩める組込機器向けウェブコンテンツのパフォーマンス
HTML5 Conference 2015 悩める組込機器向けウェブコンテンツのパフォーマンスHTML5 Conference 2015 悩める組込機器向けウェブコンテンツのパフォーマンス
HTML5 Conference 2015 悩める組込機器向けウェブコンテンツのパフォーマンス
 
Wordpress on heroku
Wordpress on herokuWordpress on heroku
Wordpress on heroku
 
Cocos2d-x(JS) ハンズオン #06「3rd SDKの導入を簡単にするSDKBOX」
Cocos2d-x(JS) ハンズオン #06「3rd SDKの導入を簡単にするSDKBOX」Cocos2d-x(JS) ハンズオン #06「3rd SDKの導入を簡単にするSDKBOX」
Cocos2d-x(JS) ハンズオン #06「3rd SDKの導入を簡単にするSDKBOX」
 
Cocos2d-x勉強会 2014/10/05
Cocos2d-x勉強会 2014/10/05Cocos2d-x勉強会 2014/10/05
Cocos2d-x勉強会 2014/10/05
 
A 2-1 gitwebmatrix 2 から使う node.js on windows azure
A 2-1 gitwebmatrix 2 から使う node.js on windows azureA 2-1 gitwebmatrix 2 から使う node.js on windows azure
A 2-1 gitwebmatrix 2 から使う node.js on windows azure
 
Cc dx lib72-p
Cc dx lib72-pCc dx lib72-p
Cc dx lib72-p
 

Similar to Customazed CLI: カスタムVMイメージ作成支援ツール

第1回JAZUG静岡勉強会
第1回JAZUG静岡勉強会第1回JAZUG静岡勉強会
第1回JAZUG静岡勉強会
Sunao Tomita
 
Sinatraアプリをherokuにアップ
SinatraアプリをherokuにアップSinatraアプリをherokuにアップ
Sinatraアプリをherokuにアップ
Hiroshi Oyamada
 
Windows Live SkyDrive Update .NETラボ勉強会 2012-06-23 - 公開
Windows Live SkyDrive Update .NETラボ勉強会 2012-06-23 - 公開Windows Live SkyDrive Update .NETラボ勉強会 2012-06-23 - 公開
Windows Live SkyDrive Update .NETラボ勉強会 2012-06-23 - 公開
Tomokazu Kizawa
 

Similar to Customazed CLI: カスタムVMイメージ作成支援ツール (20)

Terraforming Windows Virtual Desktop Infrastructure on Azure
Terraforming Windows Virtual Desktop Infrastructure on AzureTerraforming Windows Virtual Desktop Infrastructure on Azure
Terraforming Windows Virtual Desktop Infrastructure on Azure
 
Xilinx SDSoC(2016.2)解体新書ソフトウェア編
Xilinx SDSoC(2016.2)解体新書ソフトウェア編Xilinx SDSoC(2016.2)解体新書ソフトウェア編
Xilinx SDSoC(2016.2)解体新書ソフトウェア編
 
Windows Admin Center -Project Honolulu改め-
Windows Admin Center -Project Honolulu改め-Windows Admin Center -Project Honolulu改め-
Windows Admin Center -Project Honolulu改め-
 
DroidKaigi2016 windows環境での効率的なアプリ開発手法
DroidKaigi2016 windows環境での効率的なアプリ開発手法DroidKaigi2016 windows環境での効率的なアプリ開発手法
DroidKaigi2016 windows環境での効率的なアプリ開発手法
 
Garden introduction for dea users public
Garden introduction for dea users   publicGarden introduction for dea users   public
Garden introduction for dea users public
 
2019 jetson azure_hands-on
2019 jetson azure_hands-on2019 jetson azure_hands-on
2019 jetson azure_hands-on
 
AnsibleでAzureの インフラを管理する話 + α
AnsibleでAzureの インフラを管理する話 + αAnsibleでAzureの インフラを管理する話 + α
AnsibleでAzureの インフラを管理する話 + α
 
Windows Admin Center 2018年10月のお話
Windows Admin Center 2018年10月のお話Windows Admin Center 2018年10月のお話
Windows Admin Center 2018年10月のお話
 
GitLab + Dokku で作る CI/CD 環境
GitLab + Dokku で作る CI/CD 環境GitLab + Dokku で作る CI/CD 環境
GitLab + Dokku で作る CI/CD 環境
 
第1回JAZUG静岡勉強会
第1回JAZUG静岡勉強会第1回JAZUG静岡勉強会
第1回JAZUG静岡勉強会
 
Interact2015:Host Guardian Service ってなに?(仮)
Interact2015:Host Guardian Service ってなに?(仮)Interact2015:Host Guardian Service ってなに?(仮)
Interact2015:Host Guardian Service ってなに?(仮)
 
Windows Server 2008 / R2とWindows Admin CenterとAzure Site Recovery
Windows Server 2008 / R2とWindows Admin CenterとAzure Site RecoveryWindows Server 2008 / R2とWindows Admin CenterとAzure Site Recovery
Windows Server 2008 / R2とWindows Admin CenterとAzure Site Recovery
 
Windows Admin Center on Azure
Windows Admin Center on AzureWindows Admin Center on Azure
Windows Admin Center on Azure
 
Sinatraアプリをherokuにアップ
SinatraアプリをherokuにアップSinatraアプリをherokuにアップ
Sinatraアプリをherokuにアップ
 
Android Studioの魅力
Android Studioの魅力Android Studioの魅力
Android Studioの魅力
 
Cocos2d-x v3.2を利用してシューティングゲームを作ろう!
Cocos2d-x v3.2を利用してシューティングゲームを作ろう!Cocos2d-x v3.2を利用してシューティングゲームを作ろう!
Cocos2d-x v3.2を利用してシューティングゲームを作ろう!
 
Windows Server 2012 R2 Hyper-V と Windows Azure 勘所
Windows Server 2012 R2 Hyper-V と Windows Azure 勘所Windows Server 2012 R2 Hyper-V と Windows Azure 勘所
Windows Server 2012 R2 Hyper-V と Windows Azure 勘所
 
Docker入門-基礎編 いまから始めるDocker管理【2nd Edition】
Docker入門-基礎編 いまから始めるDocker管理【2nd Edition】Docker入門-基礎編 いまから始めるDocker管理【2nd Edition】
Docker入門-基礎編 いまから始めるDocker管理【2nd Edition】
 
Windows Live SkyDrive Update .NETラボ勉強会 2012-06-23 - 公開
Windows Live SkyDrive Update .NETラボ勉強会 2012-06-23 - 公開Windows Live SkyDrive Update .NETラボ勉強会 2012-06-23 - 公開
Windows Live SkyDrive Update .NETラボ勉強会 2012-06-23 - 公開
 
C# でブロックチェーン実装
C# でブロックチェーン実装C# でブロックチェーン実装
C# でブロックチェーン実装
 

More from yaegashi

More from yaegashi (8)

go generate 完全入門
go generate 完全入門go generate 完全入門
go generate 完全入門
 
msgraph.go: Go言語で Microsoft Graph プログラミング
msgraph.go: Go言語で Microsoft Graph プログラミングmsgraph.go: Go言語で Microsoft Graph プログラミング
msgraph.go: Go言語で Microsoft Graph プログラミング
 
msgraph-sshpubkey
msgraph-sshpubkeymsgraph-sshpubkey
msgraph-sshpubkey
 
Microsoft Graph API Library for Go
Microsoft Graph API Library for GoMicrosoft Graph API Library for Go
Microsoft Graph API Library for Go
 
Raspberry Pi + Go で IoT した話
Raspberry Pi + Go で IoT した話Raspberry Pi + Go で IoT した話
Raspberry Pi + Go で IoT した話
 
golang binary hacks
golang binary hacksgolang binary hacks
golang binary hacks
 
StackExchangeで見たシステムプログラミング案件
StackExchangeで見たシステムプログラミング案件StackExchangeで見たシステムプログラミング案件
StackExchangeで見たシステムプログラミング案件
 
Ansible モジュール 作成・配布・貢献
Ansible モジュール 作成・配布・貢献Ansible モジュール 作成・配布・貢献
Ansible モジュール 作成・配布・貢献
 

Recently uploaded

2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
ssuserbefd24
 

Recently uploaded (10)

MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
MPAなWebフレームワーク、Astroの紹介 (その2) 2024/05/24の勉強会で発表されたものです。
 
20240523_IoTLT_vol111_kitazaki_v1___.pdf
20240523_IoTLT_vol111_kitazaki_v1___.pdf20240523_IoTLT_vol111_kitazaki_v1___.pdf
20240523_IoTLT_vol111_kitazaki_v1___.pdf
 
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアルLoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
LoRaWAN 4チャンネル電流センサー・コンバーター CS01-LB 日本語マニュアル
 
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
論文紹介: Exploiting semantic segmentation to boost reinforcement learning in vid...
 
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
2024年度_サイバーエージェント_新卒研修「データベースの歴史」.pptx
 
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
論文紹介: Offline Q-Learning on diverse Multi-Task data both scales and generalizes
 
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
YugabyteDB適用に向けた取り組みと隠れた魅力 (DSS Asia 2024 発表資料)
 
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
2024年5月25日Serverless Meetup大阪 アプリケーションをどこで動かすべきなのか.pptx
 
【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow【AI論文解説】Consistency ModelとRectified Flow
【AI論文解説】Consistency ModelとRectified Flow
 
Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)
Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)
Amazon Cognitoで実装するパスキー (Security-JAWS【第33回】 勉強会)
 

Customazed CLI: カスタムVMイメージ作成支援ツール

  • 1. Customazed CLI: カスタムVMイメージ作成支援ツール 2020-12-16 第30回 Tokyo Jazug Night (Online) 八重樫 剛史 Takeshi Yaegashi
  • 2. 自己紹介 2 八重樫 剛史 Takeshi Yaegashi 株式会社バンダイナムコスタジオ所属 Linux・Unix・OSS・Go 言語が好きなエンジニア 組み込みシステム開発、ゲームサーバ開発、CI/CD インフラ開発、 開発環境のクラウドシフトなどの業務に従事 活動場所 ホームページ・ブログ https://l0w.dev GitHub https://github.com/yaegashi GitLab https://gitlab.com/yaegashi Twitter https://twitter.com/hogegashi
  • 3. 今日の話題 - Customazed CLI 3 https://github.com/yaegashi/customazed ▪ CustomAZed: Customized + Azure な造語 よみ:かすためいずど? ▪ ファイルのアップロードが必要になる Azure リソース作りを支援してくれる CLI ツール ▪ Windows / macOS / Linux で動く (powered by Go) ▪ Qiita の紹介記事 Azure Advent Calendar 2020 14日目 https://qiita.com/yaegashi/items/5216a9b37c2041b93a3a
  • 4. こういうのでイラッとした経験ないですか? 4 ARM Template などで頻出する VM CustomScript Extension のリソース 実行するスクリプトを非公開 Blob ストレージに置いて SAS つき URL を渡している "properties": { "publisher": "Microsoft.Compute", "type": "CustomScriptExtension", "typeHandlerVersion": "1.8", "autoUpgradeMinorVersion": true, "settings": { "fileUris": [ "[uri(parameters('_artifactsLocation'), concat(variables('ScriptFileName'), parameters('_art ifactsLocationSasToken')))]" ], "commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -File ', variables('Scr iptFolder'), '/', variables('ScriptFileName'))]" } }
  • 5. こういうのでイラッとした経験ないですか? 5 Azure Image Builder のカスタマイザでも外部ファイル参照は出てくる 公開可能なファイルであれば GitHub に置くのでもよいが… "customize": [ { "type": "PowerShell", "name": "CreateBuildPath", "runElevated": false, "scriptUri": "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/testPs Script.ps1" }, { "type": "File", "name": "downloadBuildArtifacts", "sourceUri": "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickq uickstarts/exampleArtifacts/buildArtifacts/index.html", "destination": "c:¥¥buildArtifacts¥¥index.html" },
  • 7. Customazed CLI を使えば楽になります! 7 {{upload `script/hello.ps1`}} のように書くと、ファイルを適切なストレージ アカウントにアップロードした上で、ダウンロード URL を埋め込んでくれます { "fileUris": [ "{{upload `scripts/hello.ps1`}}" ], "commandToExecute": "powershell -ExecutionPolicy Bypass -Command {{prefix}}/scripts/hello.ps1" } { "fileUris": [ "https://customazed12345.blob.core.windows.net/customazed/9a85b47c-2e6e-508f-9c80-9dc6fb2d15 f3/scripts/hello.ps1" ], "commandToExecute": "powershell -ExecutionPolicy Bypass -Command 9a85b47c-2e6e-508f-9c80-9dc6f b2d15f3/scripts/hello.ps1" }
  • 8. Customazed CLI Example: CustomScript Extension 8 設定ファイル customazed.json を用意します (Go Template 記法) { "tenantId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "subscriptionId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "storage": { "location": "westus2", "resourceGroup": "CustomazedRG", "accountName": "customazed12345", "containerName": "customazed", "prefix": "{{hash (cfg `machine.resourceGroup`) (cfg `machine.machineName`)}}" }, "machine": { "resourceGroup": "MachineRG", "machineName": "windowsMachine" } }
  • 9. Customazed CLI Example: CustomScript Extension 9 同じ場所に customazed_machine.json と scripts/hello.ps1 を用意します { "fileUris": [ "{{upload `scripts/hello.ps1`}}" ], "commandToExecute": "powershell -ExecutionPolicy Bypass -Command {{prefix}}/scripts/hello.ps1" } Write-Host "hello, world"
  • 10. Customazed CLI Example: CustomScript Extension 10 最初に認証を行い、機能・プロバイダの登録を行います (一度だけ必要) $ customazed login 2020/12/16 16:40:02 Loading config file customazed.json 2020/12/16 16:40:02 To sign in, use a web browser to open the page https://microsoft.com/devic elogin and enter the code HN54K2H9F to authenticate. 2020/12/16 16:41:04 Saving auth-dev token in .customazed/auth_dev.json $ customazed feature register 2020/12/16 16:42:06 Loading config file customazed.json 2020/12/16 16:42:06 Loading auth-dev token in .customazed/auth_dev.json 2020/12/16 16:42:06 Feature: registering Microsoft.VirtualMachineImages/VirtualMachineTemplate Preview 2020/12/16 16:42:09 Provider: registering Microsoft.VirtualMachineImages 2020/12/16 16:42:11 Provider: registering Microsoft.KeyVault 2020/12/16 16:42:13 Provider: registering Microsoft.Compute 2020/12/16 16:42:14 Provider: registering Microsoft.Storage
  • 11. Customazed CLI Example: CustomScript Extension 11 ストレージアカウントの作成と必要なアクセス権限設定をしてくれます $ customazed setup 2020/12/16 16:44:05 Loading config file customazed.json 2020/12/16 16:44:05 Loading auth-dev token in .customazed/auth_dev.json 2020/12/16 16:44:05 Loading auth-dev token in .customazed/auth_dev.json 2020/12/16 16:44:05 Storage: creating resource group: CustomazedRG 2020/12/16 16:44:08 Storage: creating storage account: customazed12345 2020/12/16 16:44:10 Storage: creating blob container: customazed 2020/12/16 16:44:10 Identity: missing configuration 2020/12/16 16:44:10 Machine: enabling system assigned identity 2020/12/16 16:45:12 Image: missing configuration 2020/12/16 16:45:12 Gallery: missing configuration 2020/12/16 16:45:12 Builder: missing configuration 2020/12/16 16:45:12 Identity: missing configuration 2020/12/16 16:45:12 Image: missing configuration 2020/12/16 16:45:12 Gallery: missing configuration 2020/12/16 16:45:12 Role: assign role to user for blob container 2020/12/16 16:45:14 Role: assign role to machine for blob container
  • 12. Customazed CLI Example: CustomScript Extension 12 実行すると処理された customazed_machine.json を表示して確認待ちになります $ customazed machine run 2020/12/16 16:47:11 Loading config file customazed.json 2020/12/16 16:47:11 Loading auth-dev token in .customazed/auth_dev.json 2020/12/16 16:47:11 Loading custom script settings customazed_machine.json 2020/12/16 16:47:11 Blob: adding scripts/hello.ps1 2020/12/16 16:47:11 { "fileUris": [ "https://customazed12345.blob.core.windows.net/customazed/9a85b47c-2e6e-508f-9c80-9dc6f b2d15f3/scripts/hello.ps1" ], "commandToExecute": "powershell -ExecutionPolicy Bypass -Command 9a85b47c-2e6e-508f-9c80- 9dc6fb2d15f3/scripts/hello.ps1", "timestamp": 1608104831 } 2020/12/16 16:47:11 Files to upload: 1 Press ENTER to proceed:
  • 13. Customazed CLI Example: CustomScript Extension 13 実行完了後、出力結果を確認します Press ENTER to proceed: (ENTER 押した) 2020/12/16 16:47:27 Loading auth-dev token in .customazed/auth_dev.json 2020/12/16 16:47:28 Blob: destination https://customazed12345.blob.core.windows.net/custom azed/9a85b47c-2e6e-508f-9c80-9dc6fb2d15f3 2020/12/16 16:47:28 Blob: uploading scripts/hello.ps1 2020/12/16 16:47:30 Executing VM extension... 2020/12/16 16:48:30 Success: use "customazed machine show-status" to see the output $ customazed machine show-status 2020/12/16 16:50:41 Loading config file customazed.json 2020/12/16 16:50:41 Loading auth-dev token in .customazed/auth_dev.json 2020/12/16 16:50:41 ProvisioningState/succeeded: Provisioning succeeded Command execution finished 2020/12/16 16:50:41 StdOut: hello, world 2020/12/16 16:50:41 StdErr:
  • 14. Customazed CLI にできること (v0.3.1) 14 ▪ Azure VM CustomScript Extension のサポート(この資料で解説) − 手元にあるファイルを VM に送り込み、コマンド実行と結果取得が手軽にできる − Windows Linux 両方の VM に対応 ▪ Azure Image Builder のサポート(Qiita 記事で解説) − AIB に必要なユーザー割り当て ID や共有イメージギャラリーなども自動的に作ってくれる − Windows Virtual Desktop 向け VM イメージカスタマイズの CI/CD に活用 ▪ 任意テキストの処理と、それに含まれるファイルのアップロード − ARM Template などのプリプロセスに利用可能
  • 15. Customazed CLI 今後の計画 15 ▪ Azure VM RunCommand Extension サポート − CustomScript とは異なる VM コマンド実行手段 ▪ ARM Template サポート − ARM Template を直接デプロイできる − ARM TemplateSpec リソースを作成できる ▪ ZIP アップロード機能 − 複数のフォルダやファイルを自動的に ZIP ファイルにまとめてアップロード ▪ ドキュメントなどの充実