Skip to content

Commit 423c3d9

Browse files
added build and deploy scripts
1 parent efafcec commit 423c3d9

File tree

2 files changed

+198
-0
lines changed

2 files changed

+198
-0
lines changed

scripts/build.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
echo "Checking for prerequisites..."
4+
if ! type npm > /dev/null; then
5+
echo "Prerequisite Check 1: Install Node.js and NPM"
6+
exit 1
7+
fi
8+
9+
if ! type dotnet > /dev/null; then
10+
echo "Prerequisite Check 2: Install .NET Core 2.1 SDK or Runtime"
11+
exit 1
12+
fi
13+
14+
if ! type zip > /dev/null; then
15+
echo "Prerequisite Check 3: Install zip"
16+
exit 1
17+
fi
18+
19+
echo "Prerequisites satisfied"
20+
echo "******* BUILDING ARTIFACTS *******"
21+
22+
shift $((OPTIND - 1))
23+
echo "Building Categories Microservice..."
24+
HOME=`pwd`
25+
cd $HOME/categories/src/ContentReactor.Categories
26+
dotnet build
27+
dotnet test
28+
dotnet publish -c Release
29+
cd $HOME
30+
cd $HOME/categories/src/ContentReactor.Categories/ContentReactor.Categories.Api/bin/Release/netstandard2.0
31+
zip -r ContentReactor.Categories.Api.zip .
32+
cd $HOME/categories/src/ContentReactor.Categories/ContentReactor.Categories.WorkerApi/bin/Release/netstandard2.0
33+
zip -r ContentReactor.Categories.WorkerApi.zip .
34+
35+
36+
echo "Building Images Microservice..."
37+
cd $HOME/images/src/ContentReactor.Images
38+
dotnet build
39+
dotnet test
40+
dotnet publish -c Release
41+
cd $HOME
42+
cd $HOME/images/src/ContentReactor.Images/ContentReactor.Images.Api/bin/Release/netstandard2.0
43+
zip -r ContentReactor.Images.Api.zip .
44+
cd $HOME/images/src/ContentReactor.Images/ContentReactor.Images.WorkerApi/bin/Release/netstandard2.0
45+
zip -r ContentReactor.Images.WorkerApi.zip .
46+
47+
echo "Building Audio Microservice..."
48+
cd $HOME/audio/src/ContentReactor.Audio
49+
dotnet build
50+
dotnet test
51+
dotnet publish -c Release
52+
cd $HOME
53+
cd $HOME/audio/src/ContentReactor.Audio/ContentReactor.Audio.Api/bin/Release/netstandard2.0
54+
zip -r ContentReactor.Audio.Api.zip .
55+
cd $HOME/audio/src/ContentReactor.Audio/ContentReactor.Audio.WorkerApi/bin/Release/netstandard2.0
56+
zip -r ContentReactor.Audio.WorkerApi.zip .
57+
58+
echo "Building Text Microservice..."
59+
cd $HOME/text/src/ContentReactor.Text
60+
dotnet build
61+
dotnet test
62+
dotnet publish -c Release
63+
cd $HOME
64+
cd $HOME/text/src/ContentReactor.Text/ContentReactor.Text.Api/bin/Release/netstandard2.0
65+
zip -r ContentReactor.Text.Api.zip .
66+

scripts/deploy.sh

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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 an unique suffix string (recommended to autogenerate string to guarantee uniqueness): "
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+
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+
53+
# Images Microservice Deploy
54+
55+
echo "Starting deploy of Images Microservice..."
56+
az group create -n ContentReactor-Images -l westus2
57+
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
58+
59+
IMAGES_API_NAME=crimgapi$uniqueSuffixString
60+
IMAGES_WORKER_API_NAME=crimgwapi$uniqueSuffixString
61+
62+
echo "Creating Images Blob Storage..."
63+
IMAGES_BLOB_STORAGE_ACCOUNT_NAME=crimgblob$uniqueSuffixString
64+
az storage container create --account-name $IMAGES_BLOB_STORAGE_ACCOUNT_NAME --name fullimages
65+
az storage container create --account-name $IMAGES_BLOB_STORAGE_ACCOUNT_NAME --name previewimages
66+
67+
echo "Creating CORS Policy for Blob Storage"
68+
az storage cors clear --account-name $IMAGES_BLOB_STORAGE_ACCOUNT_NAME --services b
69+
az storage cors add --account-name $IMAGES_BLOB_STORAGE_ACCOUNT_NAME --services b --methods POST GET PUT --origins * --allowed-headers * --exposed-headers *
70+
71+
echo "Deploying Images Functions..."
72+
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
73+
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
74+
75+
echo "Deploying Event Grid Subscription for Images"
76+
az account set --subscription $subscriptionId
77+
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
78+
79+
# Audio Microservice Deploy
80+
81+
echo "Starting deploy of Audio Microservice..."
82+
az group create -n ContentReactor-Audio -l westus2
83+
az group deployment create -g ContentReactor-Audio --template-file $HOME/audio/deploy/microservice.json --parameters uniqueResourceNameSuffix=$uniqueSuffixString eventGridTopicName=$EVENT_GRID_TOPIC_NAME --mode Complete
84+
85+
AUDIO_API_NAME=craudapi$uniqueSuffixString
86+
AUDIO_WORKER_API_NAME=craudwapi$uniqueSuffixString
87+
88+
echo "Creating Audio Blob Storage..."
89+
=AUDIO_BLOB_STORAGE_ACCOUNT_NAME=craudblob$uniqueSuffixString
90+
az storage container create --account-name $AUDIO_BLOB_STORAGE_ACCOUNT_NAME --name audio
91+
92+
echo "Creating CORS Policy for Blob Storage"
93+
=az storage cors clear --account-name $AUDIO_BLOB_STORAGE_ACCOUNT_NAME --services b
94+
az storage cors add --account-name $AUDIO_BLOB_STORAGE_ACCOUNT_NAME --services b --methods POST GET PUT --origins * --allowed-headers * --exposed-headers *
95+
96+
echo "Deploying Audio Functions..."
97+
=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
98+
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
99+
100+
echo "Deploying Event Grid Subscription for Audio"
101+
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
102+
103+
# Text Microservice Deploy
104+
105+
echo "Starting deploy of Text Microservice..."
106+
az group create -n ContentReactor-Text -l westus2
107+
az group deployment create -g ContentReactor-Text --template-file $HOME/text/deploy/microservice.json --parameters uniqueResourceNameSuffix=$uniqueSuffixString eventGridTopicName=$EVENT_GRID_TOPIC_NAME --mode Complete
108+
109+
echo "Creating Text Blob Storage..."
110+
TEXT_BLOB_STORAGE_ACCOUNT_NAME=crtxtdb$uniqueSuffixString
111+
az cosmosdb database create --name $TEXT_BLOB_STORAGE_ACCOUNT_NAME --db-name Text --resource-group ContentReactor-Text
112+
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
113+
114+
echo "Deploying Text Functions..."
115+
TEXT_API_NAME=crtxtapi$uniqueSuffixString
116+
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
117+
118+
# Deploy Proxy
119+
echo "Starting deploy of Proxy..."
120+
az group create -n ContentReactor-Proxy -l westus2
121+
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
122+
PROXY_API_NAME=crapiproxy$uniqueSuffixString
123+
az webapp deployment source config-zip --resource-group ContentReactor-Proxy --name $PROXY_API_NAME --src $HOME/proxy/proxies/proxies.zip
124+
125+
# Deploy Web
126+
#cho "Starting deploy of Web..."
127+
#az group create -n ContentReactor-Web -l westus2
128+
129+
#az group deployment create --name ContentReactorWeb-Deployment --resource-group ContentReactor-Web --template-file $HOME/web/deploy/template.json --parameters uniqueResourceNameSuffix=$uniqueSuffixString functionAppProxyName=crapiproxy$uniqueSuffixString
130+
#WEB_APP_NAME=crweb$uniqueSuffixString
131+
132+
#az webapp deployment source config-zip --resource-group ContentReactor-Web --name $WEB_APP_NAME --src $HOME/web/src/signalr-web/SignalRMiddleware/SignalRMiddleware/obj/Release/netcoreapp2.1/SignalRMiddleware.dll

0 commit comments

Comments
 (0)