Coder Social home page Coder Social logo

aca-service-bus-sample's Introduction

利用方法

環境変数の宣言

.env ファイルの内容を適宜書き換え、読み込みます

source .env

リソースグループの作成

az group create --name "$RESOURCE_GROUP" --location "$LOCATION"

Service Busの構築

export SERVICE_BUS_NAMESPACE=ksservicebus2024
export SERVICE_BUS_QUEUE_NAME=kssbqueue
az servicebus namespace create --resource-group $RESOURCE_GROUP --name $SERVICE_BUS_NAMESPACE --location $LOCATION
az servicebus queue create --resource-group $RESOURCE_GROUP --namespace-name $SERVICE_BUS_NAMESPACE --name $SERVICE_BUS_QUEUE_NAME

接続文字列の取得

export SERVICE_BUS_CONNECTION_STR=`az servicebus namespace authorization-rule keys list --resource-group $RESOURCE_GROUP --namespace-name $SERVICE_BUS_NAMESPACE --name RootManageSharedAccessKey --query primaryConnectionString --output tsv`

Dockerイメージの作成と登録

docker build -t event_app .

(Optional) ローカルでの起動

docker run -e SERVICE_BUS_CONNECTION_STR=$SERVICE_BUS_CONNECTION_STR -e SERVICE_BUS_QUEUE_NAME=$SERVICE_BUS_QUEUE_NAME event_app

ACRの作成とイメージの登録

az acr create \
    --name "$CONTAINER_REGISTRY_NAME" \
    --resource-group "$RESOURCE_GROUP" \
    --location "$LOCATION" \
    --sku Basic \
    --admin-enabled true

docker tag event_app $CONTAINER_REGISTRY_NAME.azurecr.io/event_app:latest
az acr login --name $CONTAINER_REGISTRY_NAME
docker push $CONTAINER_REGISTRY_NAME.azurecr.io/event_app:latest

コンテナアプリ環境作成とコンテナジョブの登録

az containerapp env create --name $ENVIRONMENT --resource-group $RESOURCE_GROUP --location $LOCATION

JOB_NAME=aca-event-test-job-service-bus

az containerapp job create \
    --name "$JOB_NAME" \
    --resource-group "$RESOURCE_GROUP" \
    --env-vars "SERVICE_BUS_CONNECTION_STR=$SERVICE_BUS_CONNECTION_STR" "SERVICE_BUS_QUEUE_NAME=$SERVICE_BUS_QUEUE_NAME" \
    --environment "$ENVIRONMENT" \
    --trigger-type "Event" \
    --replica-timeout "1800" \
    --replica-retry-limit "1" \
    --replica-completion-count "1" \
    --parallelism "1" \
    --min-executions "0" \
    --max-executions "2" \
    --polling-interval "60" \
    --image "$CONTAINER_REGISTRY_NAME.azurecr.io/event_app" \
    --cpu "0.5" \
    --memory "1Gi" \
    --registry-server "$CONTAINER_REGISTRY_NAME.azurecr.io" \
    --secrets "connection-string-secret=$SERVICE_BUS_CONNECTION_STR" \
    --scale-rule-name "servicebus" \
    --scale-rule-type "azure-servicebus" \
    --scale-rule-metadata "queueName=$SERVICE_BUS_QUEUE_NAME" "namespace=$SERVICE_BUS_NAMESPACE"\
    --scale-rule-auth "connection=connection-string-secret"

動作確認

python send_service_bus.py

でメッセージを送信します。正常に動作していればコンテナアプリインスタンスが起動します。

aca-service-bus-sample's People

Contributors

mizti avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.