Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GitHub Copilot CLI で Azure Portal to Bicep

GitHub Copilot CLI で Azure Portal to Bicep

第59回 Tokyo Jazug Night
https://jazug.connpass.com/event/384470/

Avatar for Yuta Matsumura

Yuta Matsumura

March 23, 2026
Tweet

More Decks by Yuta Matsumura

Other Decks in Technology

Transcript

  1. GitHub Copilot CLI で Azure Portal to Bicep 2026/03/23 Tokyo

    JAZUG Night Yuta Matsumura © 2026 Yuta Matsumura. #jazug 1
  2. 松村 優大 (MLBお兄さん) © 2026 Yuta Matsumura. #jazug 株式会社オルターブース (Chief

    Technical Architect) Microsoft MVP for Developer Technologies Microsoft Top Partner Engineer Award 2025 GitHub 公認トレーナー C#, PHP, Azure, GitHub #fukuten #devblogradio #fukuoka_mcp https://linktr.ee/tsubakimoto 2
  3. © 2026 Yuta Matsumura. #jazug 3 4/17 Global Azure @福岡を

    開催します! 登壇者・参加者を募集中です! https://jazug.connpass.com/event/384711/
  4. 使うもの • GitHub Copilot • GitHub Copilot CLI • Azure

    CLI • Microsoft Learn MCP Server • (Azure MCP Server) © 2026 Yuta Matsumura. #jazug 8
  5. GitHub Copilot CLI • GitHub Copilot のコマンドラインツール `copilot` • Visual

    Studio Code の Copilot でできることは大抵できる • おすすめの使い方は • Markdown 文章の生成 (素の Markdown が生成) • 他のコマンドライン結果を Copilot に渡す copilot -p "1行コミットメッセージを生成して: $(git diff --cached)" © 2026 Yuta Matsumura. #jazug 10
  6. // All platforms npm install -g @github/copilot // Windows winget

    install GitHub.Copilot // macOS and Linux brew install copilot-cli // Install script (macOS and Linux) curl -fsSL https://gh.io/copilot-install | bash © 2026 Yuta Matsumura. #jazug 11 インストール方法
  7. 以下の内容でBicepに関するタスクを実施してください。 1. 指定のリソースのBicepテンプレートを取得して作業フォルダに保存して - 対象のリソースグループ: `rg-jazug` - 作業フォルダ: `rg-jazug-bicep` 2.

    別リソースグループにデプロイできるように作業フォルダ内のテンプレートをパラメーター化して 3. リソースプレフィックスは推奨される省略形を使用すること - 参照: https://learn.microsoft.com/... 4. テンプレートの構成とAzure CLI(PowerShell)でのデプロイ手順を作業フォルダの `README.md` に 記載して 5. Bicepテンプレートのエラーを修正して、正常にデプロイできるようにして © 2026 Yuta Matsumura. #jazug 14
  8. 以下の内容でBicepに関するタスクを実施してください。 1. 指定のリソースのBicepテンプレートを取得して作業フォルダに保存して - 対象のリソースグループ: `rg-jazug` - 作業フォルダ: `rg-jazug-bicep` 2.

    別リソースグループにデプロイできるように作業フォルダ内のテンプレートをパラメーター化して 3. リソースプレフィックスは推奨される省略形を使用すること - 参照: https://learn.microsoft.com/... 4. テンプレートの構成とAzure CLI(PowerShell)でのデプロイ手順を作業フォルダの `README.md` に 記載して 5. Bicepテンプレートのエラーを修正して、正常にデプロイできるようにして © 2026 Yuta Matsumura. #jazug 15 Azure CLI Microsoft Learn MCP Server
  9. Microsoft Learn MCP Server • learn.microsoft.com に対して検索ができる • 3つのツールが利用可能 ©

    2026 Yuta Matsumura. #jazug 16 ツール名 用途 microsoft_docs_search ページ検索 microsoft_docs_fetch ページを Markdown 形式に変換 microsoft_code_sample_search コードサンプル検索 (言語指定可)
  10. ◐ Let me analyze the task: 1. Get Bicep templates

    from resource group `rg-jazug` … 2. Parameterize the templates for deployment … 3. Use recommended resource prefixes/abbreviations 4. Create README.md with template structure and Azure CLI … 5. Fix any Bicep template errors Let me start by: 1. Checking Azure subscription and resource group 2. Getting the resource group contents 3. Exporting Bicep templates 4. Creating the working folder structure © 2026 Yuta Matsumura. #jazug 17 タスクの計画
  11. • List Azure Subscriptions └ {"status":200,"message":"Success","results ... } • Check

    rg-jazug resource group $ az group show --name rg-jazug ... 2>&1 └ 5 lines... • List resources in rg-jazug $ az resource list --resource-group rg-jazug ... └ 10 lines... © 2026 Yuta Matsumura. #jazug 18 Azure CLI でリソース取得
  12. ◐ I can see the resources in `rg-jazug`: 1. `plan-yuta-jazug`

    - App Service Plan 2. `vnet-yuta-jazug` - Virtual Network 3. `privatelink.postgres.database.azure.com` - Privat 4. `appi-yuta-jazug` - Application Insights 5. `app-yuta-jazug` - App Service (Web App) 6. `psql-yuta-jazug` - PostgreSQL Flexible Server 7. `privatelink.postgres.database.azure.com/link-2sww - Private DNS Zone VNet Link © 2026 Yuta Matsumura. #jazug 19 出力対象リソースの確認
  13. • Create working folder and export ARM template $ New-Item

    -ItemType Directory -Path "..." -Force | Out-Null az group export --name rg-jazug ... 2>&1 | Out-File "...¥template.json" -Encoding utf8 Write-Host "Done" └ 1 line... © 2026 Yuta Matsumura. #jazug 20 テンプレートの出力
  14. • Decompile ARM template to Bicep $ az bicep decompile

    --file "...¥template.json" 2>&1 └ 4 lines... • Check exported template content $ Get-Content "...¥template.json" -First 5 └ 6 lines... ◐ The export added warnings/errors to the beginning of the JSON file. I need to re-export and redirect only the actual JSON output (not stderr). Let me do this differently. © 2026 Yuta Matsumura. #jazug 21 Bicep の作成や検証
  15. • デコンパイルにエラーがあるため、各リソースの設定を取得して手動でクリーンなBicep テンプレートを作成します。 • Get VNet details $ az network

    vnet show -g rg-jazug -n vnet-yuta-jazug -o json 2>&1 └ 72 lines... • Get App Service Plan details $ az appservice plan show -g rg-jazug -n plan-yuta-jazug -o json 2>&1 └ 77 lines... © 2026 Yuta Matsumura. #jazug 22 Bicep のエラー修正
  16. なぜ Copilot CLI でやるのか VS Code の GitHub Copilot Chat

    でも同様の作業は可能です。 しかし出力内容のコピーがしづらく、 Markdown がレンダリングされ、プ レーンテキストで扱えないことが 煩わしいこともたまにあります・・・ © 2026 Yuta Matsumura. #jazug 29
  17. Agent Skills Agent Skills とは、エージェントに能力と専門知識を与えるため仕組み。 SKILL.md やスクリプトファイルを用意し、タスクの実行を支援する。 https://agentskills.io skill-creator (anthropics/skills)

    を使い、 リソースの推奨プレフィックスのスキルを自作しました。 azure-resource-abbreviations (tsubakimoto/skills) © 2026 Yuta Matsumura. #jazug 31
  18. まとめ • CLI のほうが向いている作業・環境もあります • IaC も AI パワーで作っていくことができます •

    Azure ポータル (GUI) で作ったリソースから、ベースとなる Bicep を 生成できますが、完全コピーではないため確認必須です © 2026 Yuta Matsumura. #jazug 33