Last active
May 11, 2018 00:24
-
-
Save yuyalush/9b8b7726bab502c8a642e280f6839ad0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 名前をの設定 | |
ACR_NAME=pakuecontainerus | |
RG_NAME=pakuecontainerregistry | |
AKV_NAME=$ACR_NAME-vault | |
ACI_NAME=acr-builid | |
# レジストリの作成 | |
az group create --location eastus --name $RG_NAME | |
az acr create --resource-group $RG_NAME --name $ACR_NAME --location eastus --sku Basic | |
# Dockerfileのダウンロード | |
git clone https://github.com/Azure-Samples/acr-build-helloworld-node | |
cd acr-build-helloworld-node | |
# ビルドの実行 | |
az acr build --registry $ACR_NAME --image helloacrbuild:v1 . | |
# Key Vaultの準備 | |
az keyvault create --resource-group $RG_NAME --name $AKV_NAME | |
# Create service principal, store its password in AKV (the registry *password*) | |
# サービスプリンシパルの作成とパスワードをKey Vaultに保管 | |
az keyvault secret set \ | |
--vault-name $AKV_NAME \ | |
--name $ACR_NAME-pull-pwd \ | |
--value $(az ad sp create-for-rbac \ | |
--name $ACR_NAME-pull \ | |
--scopes $(az acr show --name $ACR_NAME --query id --output tsv) \ | |
--role reader \ | |
--query password \ | |
--output tsv) | |
# Store service principal ID in AKV (the registry *username*) | |
# サービスプリンシパルのIDをKey Vaultに保管 | |
az keyvault secret set \ | |
--vault-name $AKV_NAME \ | |
--name $ACR_NAME-pull-usr \ | |
--value $(az ad sp show --id http://$ACR_NAME-pull --query appId --output tsv) | |
# コンテナインスタンスにデプロイ | |
az container create \ | |
--resource-group $RG_NAME \ | |
--name $ACI_NAME \ | |
--image $ACR_NAME.azurecr.io/helloacrbuild:v1 \ | |
--registry-login-server $ACR_NAME.azurecr.io \ | |
--registry-username $(az keyvault secret show --vault-name $AKV_NAME --name $ACR_NAME-pull-usr --query value -o tsv) \ | |
--registry-password $(az keyvault secret show --vault-name $AKV_NAME --name $ACR_NAME-pull-pwd --query value -o tsv) \ | |
--dns-name-label $ACI_NAME-$ACR_NAME \ | |
--query "{FQDN:ipAddress.fqdn}" \ | |
--location eastus \ | |
--output table | |
# クリーンアップ | |
az group delete --yes --name $RG_NAME --no-wait | |
az ad sp delete --id http://$ACR_NAME-pull |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment