Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Azure Bicep で始める Infrastructure as Code/ace0917
Search
TonyTonyKun
August 16, 2021
Technology
620
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Azure Bicep で始める Infrastructure as Code/ace0917
2021年9月17日に開催された Azure Council Experts 定例会のセッション資料です。
TonyTonyKun
August 16, 2021
More Decks by TonyTonyKun
See All by TonyTonyKun
Azure Durable Functions で作った NL2SQL Agent の精度向上に取り組んだ話/aidevday2026
thara0402
0
470
Azure Static Web Apps の自動ビルドがタイムアウトしやすくなった状況に対応した件/global-azure2026
thara0402
0
880
Azure Durable Functions で作った NL2SQL Agent の精度向上に取り組んだ話/jat08
thara0402
0
450
これでバッチリ!Azure マルチテナントアーキテクチャ設計のコツ/jat06
thara0402
0
800
Azure Load Testing を使って Azure Functions Flex Consumption の HTTP Trigger のパフォーマンスとコストを最適化してみよう/global-azure2025
thara0402
0
390
Prompty を使って生成 AI アプリケーション開発のプロンプトを管理する/jat03
thara0402
0
100
Azure OpenAI Service で意図せず PTU モデルをデプロイして高額請求されてしまった件/jat04
thara0402
0
120
「Durable Task Scheduler」をチョイ見せ!/jat05
thara0402
0
80
Azure App Service on Linux の Sidecar に Phi-3 を配置してインテリジェントなアプリケーションを作ってみよう/jazug-anniv14
thara0402
0
1.6k
Other Decks in Technology
See All in Technology
OSC2026on_the-world-is-waiting-for-your-voice.pdf
naruoga
0
360
IR Today: Theory, Practice, and Agents
dtunkelang
0
350
FOSS4Gを活用した自治体業務DXの試み
470715
0
110
[AWS 秋のクラウドオペレーション祭り 2026]AWS DevOps Agentで変わるリリースと運用対応 ~リリース管理機能と Directed actions のご紹介~
furuton
4
1.1k
AgentCoreで実践するハーネスエンジニアリング
yakumo
1
290
Codex概要
ymiya55
0
450
ログラスのマルチプロダクトを 支える認証基盤 〜テナントごとに異なる統制とどう向き合うか〜
dada4386
3
410
全人類(ほぼ)AWS Organizations の上でAWSを利用している、その世界を知る話
htan
0
120
全PRの83%が AIレビューだけでマージできるようになった開発組織は その後どうなったか @2026/10
athug
0
110
1万名の社員が使う認証基盤で どう信頼性を担保するか?
kairim0
0
210
2026-10-01_MagicPod_QAハーネスエンジニアリングとQA組織の未来像
ynisqa1988
1
550
形式手法を使って仕様をコーディングしよう
mikanichinose
0
180
Featured
See All Featured
Claude Code のすすめ
schroneko
67
230k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
How to Talk to Developers About Accessibility
jct
2
560
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
440
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.3k
Mind Mapping
helmedeiros
1
390
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
350
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
Transcript
Azure Bicep で始める Infrastructure as Code 2021.9.17 Azure Council Experts
定例会
自己紹介 原 敏之(Toshiyuki Hara) 株式会社ネクストスケープ Microsoft Azure の導入支援やクラウドネイティブなアプリケー ション開発をしています。 https://www.nextscape.net/
Microsoft MVP for Microsoft Azure 2017 〜 ROMANCE DAWN for the new world https://gooner.hateblo.jp/ Japan Azure User Group(JAZUG) Microsoft Azure のゆるふわなコミュニティ https://jazug.connpass.com/ 2 Copyright© 2021, JAZUG All Rights Reserved.
Goal 従来の ARM テンプレートが抱える課題を解決できる Bicep の 良さを知ることで、使ってみようと感じてもらえること Bicep を使って Infrastructure
as Code をどのように実現するの かのイメージを掴んでもらうこと 3 Copyright© 2021, JAZUG All Rights Reserved.
Infrastructure as Code Microsoft Azure における Infrastructure as Code 4
Copyright© 2021, JAZUG All Rights Reserved.
Infrastructure as Code のおさらい Infrastructure as Code (IaC) は、インフラの構築作業をコード で実施する考え方のこと
5 Copyright© 2021, JAZUG All Rights Reserved. • 構築コストの増大 • 人為的なミスの発生 • 暗黙的なノウハウの発生 手順書や人手による構築 で発生する課題 • 素早く、確実に環境を再現できる • コードの再利用により、横展開が容易 • 部品化による再利用もできる • インフラ構成を標準化でき、統制が取りやすい • 都度レビューするよりも確実に統制できる • セキュリティポリシーの適用もできる インフラをコードで管理 することによるメリット Infrastructure as Code
ARM テンプレートのおさらい Azure Resource Manger (ARM) テンプレートは、Azure ポータル 上から手作業で実施しているリソース構築を自動化する仕組み Azure
のリソースを JSON で定義する テンプレートとパラメータの JSON ファイルから構成される Azure CLI / PowerShell / Azure ポータルを使ってテンプレートを実行 6 Copyright© 2021, JAZUG All Rights Reserved.
ARM テンプレートが抱える課題 ARM テンプレートの課題は、3つに分類できる 1. Azure リソースを JSON で表現するため冗長で煩雑になりやすい 2.
テンプレートファイルの部品化による再利用が難しい 3. Azure Resource Manger API の仕様が分かりにくい 7 Copyright© 2021, JAZUG All Rights Reserved. Bicep は、この2つの課題解決に取り組むプロジェクトです。
What is a Bicep Project? Bicep とは? 8 Copyright© 2021,
JAZUG All Rights Reserved.
Bicep とは Bicep は、ARM テンプレートの DSL (Domain Specific Language) 9
Copyright© 2021, JAZUG All Rights Reserved. JSON よりもシンプルな構文で書ける モジュール化とコード再利用性のサ ポートが向上 すべての Azure リソースと API バー ジョンを Day 0 サポート 現在のバージョンは v0.4 だが、 Microsoft 公式サポートの対象 Azure Resource Manager Bicep Language Compute Storage Network … az deployment create az bicep build az bicep decompile +250 RPs ARM Templates
Bicep を使い始めるには 開発環境 Bicep ファイルを作成するためのエディターが必要。 • Visual Studio Code •
Visual Studio Code 向けの Bicep 拡張機能 デプロイ環境 Bicep ファイルをデプロイするためのコマンドが必要。 • Azure CLI • Ver.2.20.0 以降で、Bicep が Azure CLI 統合されているので追加インストール不要 • PowerShell • Bicep が自動インストールされないので、手動でインストールする 10 Copyright© 2021, JAZUG All Rights Reserved.
Bicep ファイルを作成する 空の main.bicep ファイルを作成し、リソースを定義する 11 Copyright© 2021, JAZUG All
Rights Reserved. resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = { name: 'uniquestorage001' location: 'japaneast' kind: 'Storage' sku: { name: 'Standard_LRS' } }
Bicep ファイルを作成する パラメータを追加する 12 Copyright© 2021, JAZUG All Rights Reserved.
param location string = 'japaneast’ @minLength(3) @maxLength(24) param storageAccountName string = 'uniquestorage001' resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = { name: storageAccountName location: location kind: 'Storage' sku: { name: 'Standard_LRS' } }
Bicep ファイルを作成する 変数と出力を追加する 13 Copyright© 2021, JAZUG All Rights Reserved.
param location string = 'japaneast’ @minLength(3) @maxLength(24) param storageAccountName string = 'uniquestorage001' var storageSku = 'Standard_LRS' resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = { name: storageAccountName location: location kind: 'Storage' sku: { name: storageSku } } output storageId string = stg.id
Bicep ファイルをデプロイする Bicep ファイルをリソースグループにデプロイする リソースグループの以外のデプロイ スコープ サブスクリプション 管理グループ テナント 14
Copyright© 2021, JAZUG All Rights Reserved. $ az group create -n <ResourceGroup Name> -l japaneast $ az deployment group create -f ./main.bicep -g <ResourceGroup Name>
Bicep ファイルをデプロイする パラメータを使用してデプロイする コマンドラインでパラメータを渡す パラメータの JSON ファイルを使用する • ARM テンプレートと同じパラメータ
JSON ファイルを使用できる 15 Copyright© 2021, JAZUG All Rights Reserved. $ az deployment group create -f ./main.bicep -g <ResourceGroup Name> --parameters location= japaneast storageAccountName=uniquelogstorage001 $ az deployment group create -f ./main.bicep -g <ResourceGroup Name> --parameters ./parameters.json
What unique benefits do you get with Bicep? Bicep の良いところ
16 Copyright© 2021, JAZUG All Rights Reserved.
JSON よりもシンプルな構文で書ける パラメータと変数の参照 パラメータの定義 17 Copyright© 2021, JAZUG All Rights
Reserved. "parameters": { "name": { "type": "string", "defaultValue": "myName" } }, param name string = 'myName' "name": "[variables('name')]", "location": "[parameters('location')]", name: name location: location ARM テンプレート Bicep ARM テンプレート Bicep
JSON よりもシンプルな構文で書ける パラメータの修飾 18 Copyright© 2021, JAZUG All Rights Reserved.
"parameters": { "name": { "type": "string", "defaultValue": "myName", "allowed": [ "myName", "myOtherName" ], "minLength": 3, "maxLength": 24 } }, @allowed([ 'myName' 'myOtherName' ]) @minLength(3) @maxLength(24) param name string = 'myName' ARM テンプレート Bicep
JSON よりもシンプルな構文で書ける 変数の定義 アウトプットの定義 19 Copyright© 2021, JAZUG All Rights
Reserved. "variables": { "location": “japaneast" } var location = ‘japaneast' "outputs": { "myOutput": { "type": "string", "value": "my output value" } } output myOutput string = 'my output value' ARM テンプレート Bicep ARM テンプレート Bicep
JSON よりもシンプルな構文で書ける 文字列の連結 リソース ID の取得 論理演算子 20 Copyright© 2021,
JAZUG All Rights Reserved. concat('John', ' ', parameters('lastName')) 'John ${lastName}' resourceId('microsoft.network/virtualNetworks') res.id and(parameter('isMonday'), parameter('isNovember')) isMonday && isNovember ARM テンプレート Bicep ARM テンプレート Bicep ARM テンプレート Bicep
モジュール化とコード再利用性のサポー トが向上 module を使用して、別の .bicep ファイルを参照できる すべての .bicep ファイルをモジュールとして、相対パスで参照できる。 ARM
テンプレートでは、リンクしたい JSON ファイルをインターネット に公開する必要があった。 21 Copyright© 2021, JAZUG All Rights Reserved. module stg './storage.bicep' = { name: 'storageDeploy' params: { storageAccountName: '<YOURUNIQUESTORAGENAME>' } } output storageName array = stg.outputs.containerProps . ├── main.bicep └── storage.bicep .bicep ファイルの配置 main.bicep ファイル
モジュール化とコード再利用性のサポー トが向上 暗黙的なリソースの依存関係 22 Copyright© 2021, JAZUG All Rights Reserved.
resource appServicePlan 'Microsoft.Web/serverfarms@2021-01-15' = { name: appServicePlanName location: location sku: { name: sku } } resource appService 'Microsoft.Web/sites@2021-01-15' = { name: appServicenName location: location properties:{ serverFarmId: appServicePlan.id } } ✓ あるリソース名が別のリソース定義内で参照されると、 暗黙的なリソースの依存関係が作成される。 ✓ ARM テンプレートでは、”dependsOn” で明示的に宣 言する必要があった。
Conclusion まとめ 23 Copyright© 2021, JAZUG All Rights Reserved.
まとめ いま Azure で IaC を実現するなら、推しは Bicep です。 ARM テンプレートの
JSON よりもシンプルな構文で書くことができ、 モジュール化とコードの再利用性のサポートが向上しています。 手順書や人手によるインフラ構築から脱却しましょう。 既に Terraform などのツールを導入しているなら、無理に Bicep を導入 する必要はないと思います。 24 Copyright© 2021, JAZUG All Rights Reserved.
参考資料 Azure Bicep の公式ドキュメント https://docs.microsoft.com/ja-jp/azure/azure-resource-manager/bicep/ Bicep を使用して Azure でリソースをデプロイして管理する https://docs.microsoft.com/ja-jp/learn/paths/bicep-deploy/
Project Bicep - Tutorial https://github.com/Azure/bicep/tree/main/docs/tutorial Project Bicep - Spec https://github.com/Azure/bicep/tree/main/docs/spec 25 Copyright© 2021, JAZUG All Rights Reserved.