|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +echo "Provide Service Principal App ID: " |
| 4 | +read servicePrincipalAppId |
| 5 | + |
| 6 | +echo "Provide Service Principal Password: " |
| 7 | +read servicePrincipalPassword |
| 8 | + |
| 9 | +echo "Provide Service Principal Tenant ID: " |
| 10 | +read servicePrincipalTenantId |
| 11 | + |
| 12 | +echo "Provide subscription ID: " |
| 13 | +read subscriptionId |
| 14 | + |
| 15 | +HOME=`pwd` |
| 16 | +echo "Provide any unique suffix string (max length 15 characters, recommended to autogenerate a string): " |
| 17 | +read uniqueSuffixString |
| 18 | + |
| 19 | +echo "Provide Big Huge Thesaurus API Key: " |
| 20 | +read bigHugeThesaurusApiKey |
| 21 | + |
| 22 | +az login --service-principal --username $servicePrincipalAppId --password $servicePrincipalPassword --tenant $servicePrincipalTenantId |
| 23 | +az account set --subscription $subscriptionId |
| 24 | + |
| 25 | +# Creating Event Grid Topic |
| 26 | + |
| 27 | +echo "Creating Event Grid Topic..." |
| 28 | +az group create -n ContentReactor-Events -l westus2 |
| 29 | +EVENT_GRID_TOPIC_NAME=contentreactor$uniqueSuffixString |
| 30 | +az group deployment create -g ContentReactor-Events --template-file $HOME/events/deploy/template.json --mode Complete --parameters uniqueResourceNameSuffix=$uniqueSuffixString |
| 31 | +sleep 2 |
| 32 | +# Categories Microservice Deploy |
| 33 | + |
| 34 | +echo "Starting deploy of Categories Microservice..." |
| 35 | +az group create -n ContentReactor-Categories -l westus2 |
| 36 | +az group deployment create -g ContentReactor-Categories --template-file $HOME/categories/deploy/microservice.json --parameters uniqueResourceNameSuffix=$uniqueSuffixString eventsResourceGroupName=ContentReactor-Events eventGridTopicName=$EVENT_GRID_TOPIC_NAME bigHugeThesaurusApiKey=$bigHugeThesaurusApiKey --mode Complete |
| 37 | + |
| 38 | +CATEGORIES_API_NAME=crcatapi$uniqueSuffixString |
| 39 | +CATEGORIES_WORKER_API_NAME=crcatwapi$uniqueSuffixString |
| 40 | + |
| 41 | +echo "Creating Cosmos DB entries..." |
| 42 | +COSMOS_DB_ACCOUNT_NAME=crcatdb$uniqueSuffixString |
| 43 | +az cosmosdb database create --name $COSMOS_DB_ACCOUNT_NAME --db-name Categories --resource-group ContentReactor-Categories |
| 44 | +az cosmosdb collection create --name $COSMOS_DB_ACCOUNT_NAME --db-name Categories --collection-name Categories --resource-group ContentReactor-Categories --partition-key-path "/userId" --throughput 1000 |
| 45 | + |
| 46 | +echo "Deploying Categories Functions..." |
| 47 | +az webapp deployment source config-zip --resource-group ContentReactor-Categories --name $CATEGORIES_API_NAME --src $HOME/categories/src/ContentReactor.Categories/ContentReactor.Categories.Api/bin/Release/netstandard2.0/ContentReactor.Categories.Api.zip |
| 48 | +az webapp deployment source config-zip --resource-group ContentReactor-Categories --name $CATEGORIES_WORKER_API_NAME --src $HOME/categories/src/ContentReactor.Categories/ContentReactor.Categories.WorkerApi/bin/Release/netstandard2.0/ContentReactor.Categories.WorkerApi.zip |
| 49 | + |
| 50 | +echo "Deploying Event Grid Subscription for Categories" |
| 51 | +az group deployment create -g ContentReactor-Events --template-file $HOME/categories/deploy/eventGridSubscriptions.json --parameters eventGridTopicName=$EVENT_GRID_TOPIC_NAME microserviceResourceGroupName=ContentReactor-Categories microserviceFunctionsWorkerApiAppName=$CATEGORIES_WORKER_API_NAME |
| 52 | +sleep 5 |
| 53 | + |
| 54 | +# Images Microservice Deploy |
| 55 | + |
| 56 | +echo "Starting deploy of Images Microservice..." |
| 57 | +az group create -n ContentReactor-Images -l westus2 |
| 58 | +az group deployment create -g ContentReactor-Images --template-file $HOME/images/deploy/microservice.json --parameters uniqueResourceNameSuffix=$uniqueSuffixString eventsResourceGroupName=ContentReactor-Events eventGridTopicName=$EVENT_GRID_TOPIC_NAME --mode Complete |
| 59 | + |
| 60 | +IMAGES_API_NAME=crimgapi$uniqueSuffixString |
| 61 | +IMAGES_WORKER_API_NAME=crimgwapi$uniqueSuffixString |
| 62 | +sleep 1 |
| 63 | +echo "Creating Images Blob Storage..." |
| 64 | +IMAGES_BLOB_STORAGE_ACCOUNT_NAME=crimgblob$uniqueSuffixString |
| 65 | +az storage container create --account-name $IMAGES_BLOB_STORAGE_ACCOUNT_NAME --name fullimages |
| 66 | +az storage container create --account-name $IMAGES_BLOB_STORAGE_ACCOUNT_NAME --name previewimages |
| 67 | + |
| 68 | +echo "Creating CORS Policy for Blob Storage" |
| 69 | +az storage cors clear --account-name $IMAGES_BLOB_STORAGE_ACCOUNT_NAME --services b |
| 70 | +az storage cors add --account-name $IMAGES_BLOB_STORAGE_ACCOUNT_NAME --services b --methods POST GET PUT --origins "*" --allowed-headers "*" --exposed-headers "*" |
| 71 | + |
| 72 | +echo "Deploying Images Functions..." |
| 73 | +az webapp deployment source config-zip --resource-group ContentReactor-Images --name $IMAGES_API_NAME --src $HOME/images/src/ContentReactor.Images/ContentReactor.Images.Api/bin/Release/netstandard2.0/ContentReactor.Images.Api.zip |
| 74 | +sleep 2 |
| 75 | +az webapp deployment source config-zip --resource-group ContentReactor-Images --name $IMAGES_WORKER_API_NAME --src $HOME/images/src/ContentReactor.Images/ContentReactor.Images.WorkerApi/bin/Release/netstandard2.0/ContentReactor.Images.WorkerApi.zip |
| 76 | + |
| 77 | +echo "Deploying Event Grid Subscription for Images" |
| 78 | +az account set --subscription $subscriptionId |
| 79 | +az group deployment create -g ContentReactor-Events --template-file $HOME/images/deploy/eventGridSubscriptions.json --parameters eventGridTopicName=$EVENT_GRID_TOPIC_NAME microserviceResourceGroupName=ContentReactor-Images microserviceFunctionsWorkerApiAppName=$IMAGES_WORKER_API_NAME |
| 80 | +sleep 5 |
| 81 | + |
| 82 | +# Audio Microservice Deploy |
| 83 | + |
| 84 | +echo "Starting deploy of Audio Microservice..." |
| 85 | +az group create -n ContentReactor-Audio -l westus2 |
| 86 | +az group deployment create -g ContentReactor-Audio --template-file $HOME/audio/deploy/microservice.json --parameters uniqueResourceNameSuffix=$uniqueSuffixString eventsResourceGroupName=ContentReactor-Events eventGridTopicName=$EVENT_GRID_TOPIC_NAME --mode Complete |
| 87 | + |
| 88 | +AUDIO_API_NAME=craudapi$uniqueSuffixString |
| 89 | +AUDIO_WORKER_API_NAME=craudwapi$uniqueSuffixString |
| 90 | + |
| 91 | +echo "Creating Audio Blob Storage..." |
| 92 | +AUDIO_BLOB_STORAGE_ACCOUNT_NAME=craudblob$uniqueSuffixString |
| 93 | +az storage container create --account-name $AUDIO_BLOB_STORAGE_ACCOUNT_NAME --name audio |
| 94 | + |
| 95 | +echo "Creating CORS Policy for Blob Storage" |
| 96 | +az storage cors clear --account-name $AUDIO_BLOB_STORAGE_ACCOUNT_NAME --services b |
| 97 | +az storage cors add --account-name $AUDIO_BLOB_STORAGE_ACCOUNT_NAME --services b --methods POST GET PUT --origins "*" --allowed-headers "*" --exposed-headers "*" |
| 98 | + |
| 99 | +echo "Deploying Audio Functions..." |
| 100 | +az webapp deployment source config-zip --resource-group ContentReactor-Audio --name $AUDIO_API_NAME --src $HOME/audio/src/ContentReactor.Audio/ContentReactor.Audio.Api/bin/Release/netstandard2.0/ContentReactor.Audio.Api.zip |
| 101 | +sleep 3 |
| 102 | +az webapp deployment source config-zip --resource-group ContentReactor-Audio --name $AUDIO_WORKER_API_NAME --src $HOME/audio/src/ContentReactor.Audio/ContentReactor.Audio.WorkerApi/bin/Release/netstandard2.0/ContentReactor.Audio.WorkerApi.zip |
| 103 | + |
| 104 | +echo "Deploying Event Grid Subscription for Audio" |
| 105 | +az group deployment create -g ContentReactor-Events --template-file $HOME/audio/deploy/eventGridSubscriptions.json --parameters eventGridTopicName=$EVENT_GRID_TOPIC_NAME microserviceResourceGroupName=ContentReactor-Audio microserviceFunctionsWorkerApiAppName=$AUDIO_WORKER_API_NAME |
| 106 | +sleep 5 |
| 107 | + |
| 108 | +# Text Microservice Deploy |
| 109 | + |
| 110 | +echo "Starting deploy of Text Microservice..." |
| 111 | +az group create -n ContentReactor-Text -l westus2 |
| 112 | +az group deployment create -g ContentReactor-Text --template-file $HOME/text/deploy/microservice.json --parameters uniqueResourceNameSuffix=$uniqueSuffixString eventsResourceGroupName=ContentReactor-Events eventGridTopicName=$EVENT_GRID_TOPIC_NAME --mode Complete |
| 113 | + |
| 114 | +echo "Creating Text Blob Storage..." |
| 115 | +TEXT_BLOB_STORAGE_ACCOUNT_NAME=crtxtdb$uniqueSuffixString |
| 116 | +az cosmosdb database create --name $TEXT_BLOB_STORAGE_ACCOUNT_NAME --db-name Text --resource-group ContentReactor-Text |
| 117 | +az cosmosdb collection create --name $TEXT_BLOB_STORAGE_ACCOUNT_NAME --db-name Text --collection-name Text --resource-group ContentReactor-Text --partition-key-path "/userId" --throughput 1000 |
| 118 | + |
| 119 | +echo "Deploying Text Functions..." |
| 120 | +TEXT_API_NAME=crtxtapi$uniqueSuffixString |
| 121 | +az webapp deployment source config-zip --resource-group ContentReactor-Text --name $TEXT_API_NAME --src $HOME/text/src/ContentReactor.Text/ContentReactor.Text.Api/bin/Release/netstandard2.0/ContentReactor.Text.Api.zip |
| 122 | + |
| 123 | +# Deploy Proxy |
| 124 | +echo "Starting deploy of Proxy..." |
| 125 | +az group create -n ContentReactor-Proxy -l westus2 |
| 126 | +az group deployment create -g ContentReactor-Proxy --template-file $HOME/proxy/deploy/template.json --parameters uniqueResourceNameSuffix=$uniqueSuffixString categoriesMicroserviceApiAppName=$CATEGORIES_API_NAME imagesMicroserviceApiAppName=$IMAGES_API_NAME audioMicroserviceApiAppName=$AUDIO_API_NAME textMicroserviceApiAppName=$TEXT_API_NAME --mode Complete |
| 127 | +PROXY_API_NAME=crapiproxy$uniqueSuffixString |
| 128 | +az webapp deployment source config-zip --resource-group ContentReactor-Proxy --name $PROXY_API_NAME --src $HOME/proxy/proxies/proxies.zip |
| 129 | + |
| 130 | +# Deploy Web |
| 131 | +echo "Starting deploy of Web..." |
| 132 | +az group create -n ContentReactor-Web -l westus2 |
| 133 | + |
| 134 | +az group deployment create --name ContentReactorWeb-Deployment --resource-group ContentReactor-Web --template-file $HOME/web/deploy/template.json --parameters uniqueResourceNameSuffix=$uniqueSuffixString functionAppProxyName=crapiproxy$uniqueSuffixString |
| 135 | +WEB_APP_NAME=crweb$uniqueSuffixString |
| 136 | +webInstrumentationKey=$(az resource show --namespace microsoft.insights --resource-type components --name $WEB_APP_NAME-ai -g ContentReactor-Web --query properties.InstrumentationKey) |
| 137 | +sed -i -e 's/\"%INSTRUMENTATION_KEY%\"/'"$webInstrumentationKey"'/g' $HOME/web/src/signalr-web/SignalRMiddleware/EventApp/src/environments/environment.ts |
| 138 | + |
| 139 | +cd $HOME/web/src/signalr-web/SignalRMiddleware/EventApp |
| 140 | +npm install |
| 141 | +npm run ubuntu-dev-build |
| 142 | + |
| 143 | +cd $HOME/web/src/signalr-web/SignalRMiddleware/SignalRMiddleware |
| 144 | +dotnet publish -c Release |
| 145 | + |
| 146 | +cd $HOME/web/src/signalr-web/SignalRMiddleware/SignalRMiddleware/bin/Release/netcoreapp2.1/publish/ |
| 147 | +zip -r SignalRMiddleware.zip . |
| 148 | + |
| 149 | +az webapp deployment source config-zip --resource-group ContentReactor-Web --name $WEB_APP_NAME --src $HOME/web/src/signalr-web/SignalRMiddleware/SignalRMiddleware/bin/Release/netcoreapp2.1/publish/SignalRMiddleware.zip |
| 150 | +az group deployment create -g ContentReactor-Events --template-file $HOME/web/deploy/eventGridSubscriptions.json --parameters eventGridTopicName=$EVENT_GRID_TOPIC_NAME appServiceName=$WEB_APP_NAME |
0 commit comments