-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomatedDeployment.sh
More file actions
59 lines (46 loc) · 2.62 KB
/
Copy pathautomatedDeployment.sh
File metadata and controls
59 lines (46 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
MIN_CHARACTERS=4
MAX_CHARACTERS=15
CANT_PARAMETERS=1
if [[ "$#" -eq "$CANT_PARAMETERS" && $1 =~ ^[a-zA-Z0-9\-]+$ && "${#1}" -ge "$MIN_CHARACTERS" && "${#1}" -le "$MAX_CHARACTERS" ]]
then
CLIENTE=$1
APP_NAME=bot-adopcion-msteams-$CLIENTE-prod
RESOURCE_GROUP=rg-prod-Sally-southbr
SUBSCRIPTION_ID=259fbe6e-d5f6-445c-be5e-7461f7195c28
CONTAINER_NAME="imagenes-$APP_NAME"
STORAGE_ACCOUNT=botdepot
az account set --subscription $SUBSCRIPTION_ID
#echo "Seleccionada la subscription con id: $SUBSCRIPTION_ID"
APP_ID=$(az ad app create --display-name "Bot MS Teams - $CLIENTE" --password "AtLeastSixteenCharacters_0" --available-to-other-tenants --query 'appId' -o tsv)
#echo "MicrosoftAppId: $APP_ID"
PASSWORD=$(az ad app credential reset --id $APP_ID --append --query 'password' -o tsv)
#echo "MicrosoftAppPassword: $PASSWORD"
BLOB_URL="https://$STORAGE_ACCOUNT.blob.core.windows.net/$CONTAINER_NAME"
az storage container create --resource-group "$RESOURCE_GROUP" --account-name "$STORAGE_ACCOUNT" --name "$CONTAINER_NAME" --auth-mode login
az deployment group create --resource-group "$RESOURCE_GROUP" \
--template-file ".\DeploymentTemplates\template-with-preexisting-rg.json" \
--parameters appId="$APP_ID" \
appSecret="$PASSWORD" \
botId="$APP_NAME" \
newWebAppName="$APP_NAME" \
existingAppServicePlan="Logicalis-Sally" \
appServicePlanLocation="Brazil South" \
--name "$APP_NAME"
az bot prepare-deploy --lang Csharp --code-dir "." --proj-file-path "QnABot.csproj"
#TODO: Completar valores en appsettigs.json automaticamente y generar el zip
#zip -r bot-adopcion-msteams.zip ./
echo "Editar el archivo appsetting.json y completar con los siguientes valores"
echo "MicrosoftAppId: $APP_ID"
echo "MicrosoftAppPassword: $PASSWORD"
echo "BlobImagesUrl: $BLOB_URL"
echo "-----------------------------------------------------------------"
echo "Nombre App service: $APP_NAME"
echo "Nombre Blob Container: $CONTAINER_NAME"
read -p "Una vez generado el zip presione enter para continuar"
az webapp deployment source config-zip --resource-group "$RESOURCE_GROUP" \
--name "$APP_NAME" \
--src ".\bot-msteams.zip"
else
echo "Pasar el nombre del CLIENTE sin espacios y con un máximo de 15 caracteres alfanumerocos o -"
fi