🌊

Azure Developer CLIを触ってみる

2024/05/11に公開

やること

昨月行われた、Microsoft AI Day - OsakaでAzure Developer CLIについての発表がありました。
触ったことないので、触ってみました。

https://zenn.dev/headwaters/articles/8cb09b9b179001

想定環境

  • Windows 11
  • PowerShell
  • WSL(Terraformをdeployする際に必要)
  • Terraform (v1.5.0)

Azure Developer CLIとは?

Azure Developer CLI (azd) は、ローカル開発環境から Azure へのアプリケーションの取得にかかる時間を短縮するオープンソース ツールです。 azd では、ターミナル、エディター、統合開発環境 (IDE)、CI/CD (継続的インテグレーション/継続的デプロイ) のいずれで作業しているかに関係なく、ワークフローの主要なステージにマップされる開発者向けのベスト プラクティスのコマンドが提供されます。
Azure でアプリケーションを起動して実行するために必要なすべてのものを含む拡張可能なブループリント テンプレートを使用azdできます。 これらのテンプレートには、コード資産としての再利用可能なインフラストラクチャと、独自のアプリ コードに置き換えることができる概念実証アプリケーション コードが含まれます。 独自のテンプレートを作成したり、ビルドするテンプレートを見つけたりすることもできます。

https://learn.microsoft.com/ja-jp/azure/developer/azure-developer-cli/overview

よくわからないので、とりあえず検証してみる

前準備

Power ShellにAzure Developer CLIをinstall

  1. PowerShellを開く
  2. 下記を実行し、installを行う
winget install microsoft.azd
  1. 下記を実行し、azdがinstallされていることを確認
azd version

https://learn.microsoft.com/ja-jp/azure/developer/azure-developer-cli/install-azd?tabs=winget-windows%2Cbrew-mac%2Cscript-linux&pivots=os-windows

WSLにAzure Developer CLIをinstall

  1. WSLを起動
  2. 下記を実行し、installを行う
curl -fsSL https://aka.ms/install-azd.sh | bash
  1. 下記を実行し、azdがinstallされていることを確認
azd version

https://learn.microsoft.com/ja-jp/azure/developer/azure-developer-cli/install-azd?tabs=winget-windows%2Cbrew-mac%2Cscript-linux&pivots=os-linux

テンプレートを作成

  1. 適当なディレクトで下記を実行し、フォルダー作成とディレクトリ移動を行う
 mkdir zenn; cd zenn


2. Vscodeを開く
2. 以下のコマンドを実行

azd init
  1. 「Select a template」を選択し、「Enter」を押す
  2. 適当にTemplateを選択し、「Enter」を押す
    ※今回は、Starter - Terraformを選択
  3. environment name を適当に名前を付ける
    ※今回は、Developmentと名前を付ける
  4. テンプレートができた。
  5. vscodeで開くと、テンプレートがあることを確認

テンプレート一覧

Name Source Repository Path
Event Driven Java Application with Azure Service Bus on Azure Spring Apps Awesome AZD Azure-Samples/ASA-Samples-Event-Driven-Application
Static React Web App with Java API and PostgreSQL Awesome AZD Azure-Samples/ASA-Samples-Web-Application
SAP CAP on Azure App Service Quickstart Awesome AZD Azure-Samples/app-service-javascript-sap-cap-quickstart
SAP Cloud SDK on Azure App Service Quickstart (TypeScript) Awesome AZD Azure-Samples/app-service-javascript-sap-cloud-sdk-quickstart
Java Spring Apps with Azure OpenAI Awesome AZD Azure-Samples/app-templates-java-openai-springapps
WordPress with Azure Container Apps Awesome AZD Azure-Samples/apptemplate-wordpress-on-ACA
Azure AI Starter Awesome AZD Azure-Samples/azd-ai-starter
Azure AI Studio Starter Awesome AZD Azure-Samples/azd-aistudio-starter
Bicep template to bootstrap Azure Deployment Environments Awesome AZD Azure-Samples/azd-deployment-environments
Starter - Bicep Awesome AZD Azure-Samples/azd-starter-bicep
Starter - Terraform Awesome AZD Azure-Samples/azd-starter-terraform
Dynamic Configuration for AKS workloads (w/o changing ConfigMaps or with Azure App Configuration) Awesome AZD Azure-Samples/azure-appconfig-aks
Python (Django) Web App with PostgreSQL via Azure Container Apps Awesome AZD Azure-Samples/azure-django-postgres-aca
PostgreSQL + Pgvector Awesome AZD Azure-Samples/azure-postgres-pgvector-python
ChatGPT and Enterprise data with Azure OpenAI and Cognitive Search Awesome AZD Azure-Samples/azure-search-openai-demo
ChatGPT + Enterprise Data with Azure OpenAI and Cognitive Search Awesome AZD Azure-Samples/azure-search-openai-demo-csharp
Java - ChatGPT + Enterprise data with Azure OpenAI and Cognitive Search Awesome AZD Azure-Samples/azure-search-openai-demo-java
ChatGPT and RAG with Azure OpenAI and Cognitive Search for JavaScript Awesome AZD Azure-Samples/azure-search-openai-javascript
Azure OpenAI Conference Session Recommender Awesome AZD Azure-Samples/azure-sql-db-session-recommender
Azure OpenAI Conference Session Assistant Awesome AZD Azure-Samples/azure-sql-db-session-recommender-v2
Microservices App - Dapr Bindings Cron C# ACA PostgreSQL Awesome AZD Azure-Samples/bindings-dapr-csharp-cron-postgres
Microservices App - Dapr Bindings Cron Node.js ACA PostgreSQL Awesome AZD Azure-Samples/bindings-dapr-nodejs-cron-postgres
Microservices App - Dapr Bindings Cron Python ACA PostgreSQL Awesome AZD Azure-Samples/bindings-dapr-python-cron-postgres
Chat with your Data Solution Accelerator Awesome AZD Azure-Samples/chat-with-your-data-solution-accelerator
Simple Chat Application using Azure OpenAI Awesome AZD Azure-Samples/chatgpt-quickstart
Enterprise-Grade Reference Architecture for JavaScript Awesome AZD Azure-Samples/contoso-real-estate
FastAPI on Azure Functions Awesome AZD Azure-Samples/fastapi-on-azure-functions
Azure Functions - Text Summarization using AI Cognitive Language Service (C#-Isolated) Awesome AZD Azure-Samples/function-csharp-ai-textsummarize
Azure Function with Event Hub with optional virtual network capabilities Awesome AZD Azure-Samples/function-eventhub-vnet
Azure Functions - Chat using ChatGPT (Node.js JavaScript Function) Awesome AZD Azure-Samples/function-javascript-ai-openai-chatgpt
Azure Functions - LangChain with Azure OpenAI and ChatGPT (Python v2 Function) Awesome AZD Azure-Samples/function-python-ai-langchain
Azure Functions - Chat using ChatGPT (Python v2 Function) Awesome AZD Azure-Samples/function-python-ai-openai-chatgpt
Azure Functions - Text Summarization using AI Cognitive Language Service (Python v2 Function) Awesome AZD Azure-Samples/function-python-ai-textsummarize
SAP Cloud SDK on Azure Functions Quickstart (TypeScript) Awesome AZD Azure-Samples/functions-javascript-sap-cloud-sdk-quickstart
Langfuse on Azure Awesome AZD Azure-Samples/langfuse-on-azure
Python (Django) Web App with PostgreSQL in VNet Awesome AZD Azure-Samples/msdocs-django-postgresql-sample-app
Python (Flask) Web App with PostgreSQL in VNet Awesome AZD Azure-Samples/msdocs-flask-postgresql-sample-app
Azure OpenAI priority-based load balancer with Azure Container Apps Awesome AZD Azure-Samples/openai-aca-lb
Azure API Management policy for priority-based routing to Azure OpenAI Awesome AZD Azure-Samples/openai-apim-lb
ChatGPT Plugin using Python (FastAPI) Awesome AZD Azure-Samples/openai-plugin-fastapi
Microservices App - Dapr PubSub Java AKS Awesome AZD Azure-Samples/pubsub-dapr-aks-java
Microservices App - Dapr PubSub C# ACA ServiceBus Awesome AZD Azure-Samples/pubsub-dapr-csharp-servicebus
Microservices App - Dapr PubSub Node.js ACA ServiceBus Awesome AZD Azure-Samples/pubsub-dapr-nodejs-servicebus
Microservices App - Dapr PubSub Python ACA ServiceBus Awesome AZD Azure-Samples/pubsub-dapr-python-servicebus
React Component Toolkit with ChatGPT and OpenAI Awesome AZD Azure-Samples/react-component-toolkit-openai-demo
Serverless ChatGPT with RAG using LangChain.js Awesome AZD Azure-Samples/serverless-chat-langchainjs/
Spring ChatGPT Application using Azure OpenAI on Azure Spring Apps Awesome AZD Azure-Samples/spring-chatgpt-sample
Spring PetClinic - Java Spring MySQL Awesome AZD Azure-Samples/spring-petclinic-java-mysql
Microservices App - Dapr Service Invoke C# ACA Awesome AZD Azure-Samples/svc-invoke-dapr-csharp
Microservices App - Dapr Service Invoke Node.js ACA Awesome AZD Azure-Samples/svc-invoke-dapr-nodejs
Microservices App - Dapr Service Invoke Python ACA Awesome AZD Azure-Samples/svc-invoke-dapr-python
React Web App with C# API and MongoDB Awesome AZD Azure-Samples/todo-csharp-cosmos-sql
React Web App with C# API and SQL Database Awesome AZD Azure-Samples/todo-csharp-sql
Static React Web App + Functions with C# API and SQL Database Awesome AZD Azure-Samples/todo-csharp-sql-swa-func
React Web App with Java API and MongoDB Awesome AZD Azure-Samples/todo-java-mongo
Containerized React Web App with Java API and MongoDB Awesome AZD Azure-Samples/todo-java-mongo-aca
React Web App with Node.js API and MongoDB Awesome AZD Azure-Samples/todo-nodejs-mongo
Containerized React Web App with Node.js API and MongoDB Awesome AZD Azure-Samples/todo-nodejs-mongo-aca
Kubernetes React Web App with Node.js API and MongoDB Awesome AZD Azure-Samples/todo-nodejs-mongo-aks
Static React Web App + Functions with Node.js API and MongoDB Awesome AZD Azure-Samples/todo-nodejs-mongo-swa-func
React Web App with Node.js API and MongoDB - Terraform Awesome AZD Azure-Samples/todo-nodejs-mongo-terraform
React Web App with Python API and MongoDB Awesome AZD Azure-Samples/todo-python-mongo
Containerized React Web App with Python API and MongoDB Awesome AZD Azure-Samples/todo-python-mongo-aca
Static React Web App + Functions with Python API and MongoDB Awesome AZD Azure-Samples/todo-python-mongo-swa-func
React Web App with Python API and MongoDB - Terraform Awesome AZD Azure-Samples/todo-python-mongo-terraform
Multi-repo ChatGPT and Enterprise data with Azure OpenAI and Cognitive Search Awesome AZD Azure/GPT-RAG
Setting up Azure OpenAI as a central capability within your organization Awesome AZD Azure/enterprise-azureai
Reliable Web App Pattern for .NET Awesome AZD Azure/reliable-web-app-pattern-dotnet
Next.js on Container Apps Awesome AZD CMeeg/nextjs-aca
Remix on Container Apps Awesome AZD CMeeg/remix-aca
Real time game leaderboard with Azure Container Apps and Redis Cache Awesome AZD CawaMS/GameLeaderboard
.NET Redis OutputCache with Azure OpenAI Awesome AZD CawaMS/OutputCacheOpenAI
.NET eShop on Web App with Redis Cache Awesome AZD CawaMS/eShop
.NET Isolated Azure Function with Zip Deploy Awesome AZd FBoucher/ZipDeploy-AzFunc
DotNet Function App with Service Bus Awesome AZD Gordonby/servicebus-dotnet-functionapp
Blazor Web App with C# and SQL Database on Azure Awesome AZD JasonTaylorDev/azd-blazor
Using FastAPI Framework with Azure Functions to serve paginated data from Snowflake Awesome AZD MiguelElGallo/simple-fastapi-snow-azd
Simple Streamlit Awesome AZD MiguelElGallo/simple-streamlit-azd
Azure Kubernetes Service Store Demo Awesome AZD azure-samples/aks-store-demo
URL Shortener using Microsoft Orleans and Azure for hosting and data Awesome AZD azure-samples/orleans-url-shortener
Rock, Paper, Orleans (RPO) - Distributed .NET Awesome AZD bradygaster/RockPaperOrleans
Sample Ruby on Rails app deployed (Bicep) on Azure Container App with PostgreSQL Awesome AZD dbroeglin/azure-rails-starter
.NET AI samples with Azure OpenAI Awesome AZD dotnet/ai-samples
Azure OpenAI with Azure Bot and Custom API calling, Behind a Firewall Awesome AZD graemefoster/LockedDownChatBot
Python (Flask) Web App with MySQL and Key Vault Awesome AZD john0isaac/flask-webapp-mysql-db
RAG using Semantic Kernel with Azure OpenAI and Azure Cosmos DB for MongoDB vCore Awesome AZD john0isaac/rag-semantic-kernel-mongodb-vcore
Simple Flask (Python) Web App (Terraform) on Azure Awesome AZD john0isaac/simple-flask-app-terraform
Docusaurus with Azure Container Apps Awesome AZD jsburckhardt/docusaurus-aca
Terraform template to bootstrap Azure Deployment Environments Awesome AZD lopezleandro03/azd-devcenter
Azure Open AI management and logging via Azure API Management Awesome AZD microsoft/aoai-logging-with-apim
Python (Django) Web App with PostgreSQL and Key Vault Awesome AZD pamelafox/django-quiz-app
FastAPI with API Management Awesome AZD pamelafox/fastapi-azure-function-apim
Flask Chart API on ACA and CDN Awesome AZD pamelafox/flask-charts-api-container-app
Python (Flask) Web App with PostgreSQL Awesome AZD pamelafox/flask-db-quiz-example
Flask Container with CDN Awesome AZD pamelafox/flask-gallery-container-app
Flask Surveys Container App Awesome AZD pamelafox/flask-surveys-container-app
FastAPI on Azure Container Apps Awesome AZD pamelafox/simple-fastapi-container
Flask API on Azure Container Apps Awesome AZD pamelafox/simple-flask-api-container
Static Maps API Function and CDN Awesome AZD pamelafox/staticmaps-function
React Web App with Azure API Management exposing SAP OData APIs Awesome AZD pascalvanderheiden/ais-apim-odata-reactjs
Azure API Management with Azure OpenAI Awesome AZD pascalvanderheiden/ais-apim-openai
Service Bus messages processing to Dataverse Awesome AZD rpothin/servicebus-csharp-function-dataverse
Containerized Apps on Azure Kubernetes Service Awesome AZD sabbour/aks-app-template
Jupyter Notebooks Web App on Azure Container Apps Awesome AZD savannahostrowski/jupyter-mercury-aca
Hello world Java Application on Azure Spring Apps Awesome AZD spring-guides/gs-spring-boot-for-azure
FastAPI, htmx, TailwindCSS on App Service Awesome AZD tataraba/musicbinder-azd
Scalable Django on Azure App Service Awesome AZD tonybaloney/django-on-azure
Simple Flask AZD Awesome AZD tonybaloney/simple-flask-azd

https://learn.microsoft.com/ja-jp/azure/developer/azure-developer-cli/azd-templates?tabs=java#choose-a-template

deployしてみる

  1. wslを開く
  2. 以下のコマンドを実行し、Azureにログイン
azd login
az login -t <テナントID>
  1. 以下のコマンドを実行し、Deployする
azd up


4. デプロイ完了

5. Azureを確認すると、リソースがデプロイされていることを確認

まとめ

Azure Developer CLIを初めて使ってみました。
テンプレートとしては、かなり使い勝手良いなーと思いました。
これをもとに開発したら、開発スピード上がりそうだなーと思いました。

ヘッドウォータース

Discussion