Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
Ammended the script to make it runnable (#1257)
Browse files Browse the repository at this point in the history
* Update azurescript.sh

* Change path to the dockerfile

* Made the script execute correctly
  • Loading branch information
davidheerema committed Feb 3, 2020
1 parent f05d862 commit 1bb6071
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions utils/azurescript.sh
@@ -1,14 +1,15 @@
#!/bin/bash

export PROJECT_NAME=rcmpcybercrime
export RG_NAME=MpSCCDSCybercrimeRG
export ACR_NAME=MpSCCDSCybercrimeacr
export RG_NAME=MpPCCDSCybercrimeRG
export ACR_NAME=MpPCCDSCybercrimeacr
export IMAGE_NAME=f2
export DB_NAME=mpsccdscybercrimecosdb
export PLAN_NAME=MpSCCDSCybercrimeazappplan
export APP_NAME=MpSCCDSCybercrimeazapp
export SERVICE_PRINCIPAL_NAME=MpSCCDSCybercrimeACR-sp
export VIRUS_SCANNER_NAME=mpsccdscybercrimeclamav
export DB_NAME=mppccdscybercrimecosdb
export PLAN_NAME=MpPCCDSCybercrimeazappplan
export APP_NAME=MpPCCDSCybercrimeazapp
export SERVICE_PRINCIPAL_NAME=MpPCCDSCybercrimeACR-sp
export VIRUS_SCANNER_NAME=mppccdscybercrimeclamav
export COGNITIVE_NAME=MpPCCogContMod1
export WAF_RG=MpPCCorenetRg
export WAF_NAME=MpPCWafGw
export WAF_FRONTEND_IP=appGatewayFrontendIP
Expand All @@ -18,23 +19,26 @@ export WAF_SUBSCRIPTION=MpPSub
az group create --name $RG_NAME --location canadacentral
az configure --defaults group=$RG_NAME location=canadacentral # set default resource group
## Container registry
az acr create --name $ACR_NAME --sku standard
ACR_REGISTRY_ID=$(az acr create --name $ACR_NAME --sku standard --query id --output tsv)
## Database
az cosmosdb create --name $DB_NAME --kind MongoDB
## Antivirus Scanner
az container create --resource-group $RG_NAME --name $VIRUS_SCANNER_NAME --image mk0x/docker-clamav:alpine --dns-name-label $VIRUS_SCANNER_NAME --ports 3310
## Antivirus Scanner - Currently not using the alpine version because mk0x needs to rebuild from clamd v102.2 or 103 to pickup known azure bugfix.
# See https://bugzilla.clamav.net/show_bug.cgi?id=12469
az container create --resource-group $RG_NAME --name $VIRUS_SCANNER_NAME --image mk0x/docker-clamav --dns-name-label $VIRUS_SCANNER_NAME --ports 3310
## Azure Cognitive Services - Content Moderator
az cognitiveservices account create --name MpSCCogContMod1 --resource-group $RG_NAME --kind ContentModerator --sku F0 --location canadacentral --yes
az cognitiveservices account create --name $COGNITIVE_NAME --resource-group $RG_NAME --kind ContentModerator --sku F0 --location canadacentral --yes
# Deploy code
## Docker image
az acr build --registry $ACR_NAME --image $IMAGE_NAME .
## App Service
### Create
az appservice plan create --name $PLAN_NAME --sku F1 --is-linux
az webapp create --name $APP_NAME --plan $PLAN_NAME --deployment-container-image-name ${ACR_NAME}.azurecr.io/${IMAGE_NAME}:latest
az acr build --registry $ACR_NAME --image $IMAGE_NAME ../f2
### ACR access
SP_PASSWD=$(az ad sp create-for-rbac --name http://$SERVICE_PRINCIPAL_NAME --scopes $ACR_REGISTRY_ID --role acrpull --query password --output tsv)
SP_APP_ID=$(az ad sp show --id http://$SERVICE_PRINCIPAL_NAME --query appId --output tsv)
## App Service
### Create
# Note: Once created it seems like I've had to restart the app service perhaps to get it working
# It may be that the service principle is taking longer to create and it's not ready by the time the app is configured...
az appservice plan create --name $PLAN_NAME --sku P1V2 --is-linux
az webapp create --name $APP_NAME --plan $PLAN_NAME --deployment-container-image-name ${ACR_NAME}.azurecr.io/${IMAGE_NAME}:latest
az webapp config container set --name $APP_NAME --resource-group $RG_NAME --docker-custom-image-name ${ACR_NAME}.azurecr.io/${IMAGE_NAME}:latest --docker-registry-server-url https://${ACR_NAME}.azurecr.io --docker-registry-server-user $SP_APP_ID --docker-registry-server-password $SP_PASSWD
### Environmental variables
export COSMO_KEY=`az cosmosdb keys list --name $DB_NAME --query "primaryMasterKey" | sed -e 's/^"//' -e 's/"$//'`
Expand Down

0 comments on commit 1bb6071

Please sign in to comment.