このリポジトリは、Azure上にベースライン環境をデプロイするためのBicepテンプレートを提供しています。Bicepを使用したInfrastructure as Code(IaC)により、様々なAzureリソースを体系的にプロビジョニングすることができます。
このプロジェクトでは、IoT、OpenAIなど、一般的なAzureソリューションのための複数のデプロイメントシナリオを提供しています。
以下の手順に従って最初の環境をデプロイしましょう:
-
リポジトリをクローン
git clone https://github.com/ks6088ts-labs/baseline-environment-on-azure-bicep.git cd baseline-environment-on-azure-bicep
-
Azureにログイン
az login
-
サブスクリプションを選択(複数ある場合)
az account set --subscription "<サブスクリプションIDまたは名前>"
-
デプロイするシナリオを選択(以下のシナリオセクションを参照)
# 例えば、exampleシナリオをデプロイする場合: cd infra make deploy SCENARIO=example
-
デプロイメントを確認
az group list -o table
-
Azureの環境情報を表示
make info
-
特定のシナリオをデプロイ
make deploy SCENARIO=<シナリオ名>
-
デプロイ前に変更をプレビュー(What-If)
make deployment-what-if SCENARIO=<シナリオ名>
-
シナリオのリソースを削除
make destroy SCENARIO=<シナリオ名>
-
Azure CLIがログインしていない
- エラー:
ERROR: Please run 'az login' to setup account.
- 解決策:
az login
を実行してAzureに認証する
- エラー:
-
権限が不足している
- エラー:
ERROR: The client has permission to perform action on resource '...' but the resource was not found.
- 解決策: アカウントに必要な権限(所有者または共同作成者)があることを確認する
- エラー:
-
リソース名がすでに存在する
- エラー:
Resource with name '...' already exists.
- 解決策: 別のリソースグループ名を使用するか、既存のリソースを削除する
- エラー:
This repository contains Bicep templates for deploying baseline environments on Azure. It provides a structured approach to provision various Azure resources using Infrastructure as Code (IaC) with Bicep.
The project offers multiple deployment scenarios for common Azure solutions, including IoT, OpenAI, and other services. Using this repository, you can easily deploy these scenarios to your Azure subscription with minimal effort.
Bicep is a Domain Specific Language (DSL) for deploying Azure resources. It offers a more concise syntax compared to JSON ARM templates while maintaining compatibility with Azure Resource Manager.
Before using this repository, make sure you have the following tools installed:
-
GNU Make - Used for running commands defined in the Makefile
- Windows: Install via Chocolatey:
choco install make
- macOS: Install via Homebrew:
brew install make
- Linux: Install via package manager, e.g.,
sudo apt-get install make
- Windows: Install via Chocolatey:
-
Azure CLI - Command-line tool for Azure
- Windows: Download installer
- macOS:
brew install azure-cli
- Linux: Follow these instructions
-
Azure Subscription - You need an active Azure subscription
- If you don't have one, create a free account
-
Azure CLI login - Log in to your Azure account using:
az login
-
Bicep CLI - The Bicep CLI is installed automatically with Azure CLI, but ensure it's up to date:
az bicep install az bicep upgrade
Follow these steps to deploy your first environment:
-
Clone the repository
git clone https://github.com/ks6088ts-labs/baseline-environment-on-azure-bicep.git cd baseline-environment-on-azure-bicep
-
Log in to Azure
az login
-
Select your subscription (if you have multiple)
az account set --subscription "<your-subscription-id-or-name>"
-
Choose a scenario to deploy (see Scenarios section below)
# For example, to deploy the example scenario: cd infra make deploy SCENARIO=example
-
Verify the deployment
az group list -o table
The repository uses a Makefile to simplify common operations. Here are the main commands available:
cd infra
make help # Shows available commands
-
Show information about your Azure environment
make info
-
Deploy a specific scenario
make deploy SCENARIO=<scenario-name>
-
Preview changes before deployment (What-If)
make deployment-what-if SCENARIO=<scenario-name>
-
Delete resources for a scenario
make destroy SCENARIO=<scenario-name>
-
Create a resource group manually
make create-resource-group RESOURCE_GROUP_NAME=<group-name> LOCATION=<azure-region>
-
Build a Bicep template
make build SCENARIO=<scenario-name>
You can customize deployments by:
- Modifying the parameter files in
infra/scenarios/<scenario-name>/main.parameters.bicepparam
- Setting environment variables:
# Example: Deploy to a different location make deploy SCENARIO=example LOCATION=westus2
This repository offers several deployment scenarios for various Azure services:
Scenario | Overview | Use Case |
---|---|---|
example | Basic example showing how to use modules | Getting started |
workshop-azure-iot | Workshop for Azure IoT scenario | IoT device management and data processing |
workshop-azure-openai | Workshop for Azure OpenAI Service | AI/ML applications and language models |
event-grid-mqtt | Event Grid with MQTT protocol | Event-driven architecture with MQTT |
iot-edge | IoT Edge deployment | Edge computing for IoT devices |
app-service | Azure App Service deployment | Web application hosting |
Each scenario has its own README file with specific instructions and details.
This repository includes GitHub Actions workflows to automate deployments. To configure the connection between GitHub and Azure, follow these steps:
-
Install the GitHub CLI
- Follow the installation instructions at GitHub CLI
- Authenticate with GitHub:
gh auth login
-
Create and configure the necessary Azure resources
# Create a new service principal bash scripts/create-service-principal.sh # Configure GitHub secrets bash scripts/configure-github-secrets.sh # Add permissions to the service principal (if needed) bash scripts/add-permissions-to-service-principal.sh
-
Provide information when prompted
- You'll need to enter:
- GitHub environment name (e.g., 'development', 'production')
- GitHub repository name (in format 'username/repo')
- Application name for the service principal
- You'll need to enter:
-
Verify the setup
- Check the GitHub repository settings to confirm that secrets were added properly
- Test the workflow by making a small change and pushing it to your repository
-
Azure CLI not logged in
- Error:
ERROR: Please run 'az login' to setup account.
- Solution: Run
az login
to authenticate with Azure
- Error:
-
Insufficient permissions
- Error:
ERROR: The client has permission to perform action on resource '...' but the resource was not found.
- Solution: Ensure your account has the necessary permissions (Owner or Contributor)
- Error:
-
Resource name already exists
- Error:
Resource with name '...' already exists.
- Solution: Use a different resource group name or delete the existing resources
- Error:
- Check Azure Bicep documentation: Microsoft Learn
- Search for error messages in Azure documentation
- Check issues in this repository
Contributions to this repository are welcome! To contribute:
- Fork the repository
- Create a new branch for your feature
- Make your changes
- Submit a pull request
See the documentation for more information about Azure landing zones and references used in this project.