Skip to content

ks6088ts-labs/baseline-environment-on-azure-bicep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

infra deploy

baseline-environment-on-azure-bicep

English | 日本語

日本語ドキュメント

概要

このリポジトリは、Azure上にベースライン環境をデプロイするためのBicepテンプレートを提供しています。Bicepを使用したInfrastructure as Code(IaC)により、様々なAzureリソースを体系的にプロビジョニングすることができます。

このプロジェクトでは、IoT、OpenAIなど、一般的なAzureソリューションのための複数のデプロイメントシナリオを提供しています。

はじめに

以下の手順に従って最初の環境をデプロイしましょう:

  1. リポジトリをクローン

    git clone https://github.com/ks6088ts-labs/baseline-environment-on-azure-bicep.git
    cd baseline-environment-on-azure-bicep
  2. Azureにログイン

    az login
  3. サブスクリプションを選択(複数ある場合)

    az account set --subscription "<サブスクリプションIDまたは名前>"
  4. デプロイするシナリオを選択(以下のシナリオセクションを参照)

    # 例えば、exampleシナリオをデプロイする場合:
    cd infra
    make deploy SCENARIO=example
  5. デプロイメントを確認

    az group list -o table

主なコマンド

  • Azureの環境情報を表示

    make info
  • 特定のシナリオをデプロイ

    make deploy SCENARIO=<シナリオ名>
  • デプロイ前に変更をプレビュー(What-If)

    make deployment-what-if SCENARIO=<シナリオ名>
  • シナリオのリソースを削除

    make destroy SCENARIO=<シナリオ名>

トラブルシューティング

  1. Azure CLIがログインしていない

    • エラー: ERROR: Please run 'az login' to setup account.
    • 解決策: az loginを実行してAzureに認証する
  2. 権限が不足している

    • エラー: ERROR: The client has permission to perform action on resource '...' but the resource was not found.
    • 解決策: アカウントに必要な権限(所有者または共同作成者)があることを確認する
  3. リソース名がすでに存在する

    • エラー: Resource with name '...' already exists.
    • 解決策: 別のリソースグループ名を使用するか、既存のリソースを削除する

Overview

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.

What is Bicep?

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.

Prerequisites

Before using this repository, make sure you have the following tools installed:

Required Tools

Azure Requirements

  • Azure Subscription - You need an active Azure subscription

  • 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

Getting Started

Follow these steps to deploy your first environment:

  1. Clone the repository

    git clone https://github.com/ks6088ts-labs/baseline-environment-on-azure-bicep.git
    cd baseline-environment-on-azure-bicep
  2. Log in to Azure

    az login
  3. Select your subscription (if you have multiple)

    az account set --subscription "<your-subscription-id-or-name>"
  4. Choose a scenario to deploy (see Scenarios section below)

    # For example, to deploy the example scenario:
    cd infra
    make deploy SCENARIO=example
  5. Verify the deployment

    az group list -o table

Usage

The repository uses a Makefile to simplify common operations. Here are the main commands available:

cd infra
make help  # Shows available commands

Common 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>

Customizing Deployments

You can customize deployments by:

  1. Modifying the parameter files in infra/scenarios/<scenario-name>/main.parameters.bicepparam
  2. Setting environment variables:
    # Example: Deploy to a different location
    make deploy SCENARIO=example LOCATION=westus2

Scenarios

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.

Use GitHub Actions to connect to Azure

This repository includes GitHub Actions workflows to automate deployments. To configure the connection between GitHub and Azure, follow these steps:

Setting up GitHub Actions with Azure

  1. Install the GitHub CLI

    • Follow the installation instructions at GitHub CLI
    • Authenticate with GitHub:
      gh auth login
  2. 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
  3. 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
  4. 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

Troubleshooting

Common Issues

  1. Azure CLI not logged in

    • Error: ERROR: Please run 'az login' to setup account.
    • Solution: Run az login to authenticate with Azure
  2. 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)
  3. Resource name already exists

    • Error: Resource with name '...' already exists.
    • Solution: Use a different resource group name or delete the existing resources

Getting Help

Contributing

Contributions to this repository are welcome! To contribute:

  1. Fork the repository
  2. Create a new branch for your feature
  3. Make your changes
  4. Submit a pull request

See the documentation for more information about Azure landing zones and references used in this project.

About

Baseline Environment on Azure in Bicep is a set of reference Bicep template

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •