-
Notifications
You must be signed in to change notification settings - Fork 21
/
setup.sh
75 lines (35 loc) · 1.79 KB
/
setup.sh
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
apiappname=CensusDataAPI$(openssl rand -hex 5)
printf "Setting username and password for Git ... (1/7)\n\n"
GIT_USERNAME=gitName$Random
GIT_EMAIL=a@b.c
git config --global user.name "$GIT_USERNAME"
git config --global user.email "$GIT_EMAIL"
RESOURCE_GROUP=$(az group list --query "[0].name" -o tsv)
# Create App Service plan
PLAN_NAME=myPlan
printf "\nCreating App Service plan in FREE tier ... (2/7)\n\n"
az appservice plan create --name $apiappname --resource-group $RESOURCE_GROUP --sku FREE --location centralus --verbose
printf "\nCreating API App ... (3/7)\n\n"
az webapp create --name $apiappname --resource-group $RESOURCE_GROUP --plan $apiappname --deployment-local-git --verbose
printf "\nSetting the account-level deployment credentials ...(4/7)\n\n"
DEPLOY_USER="myName1$(openssl rand -hex 5)"
DEPLOY_PASSWORD="Pw1$(openssl rand -hex 10)"
az webapp deployment user set --user-name $DEPLOY_USER --password $DEPLOY_PASSWORD --verbose
GIT_URL="https://$DEPLOY_USER@$apiappname.scm.azurewebsites.net/$apiappname.git"
# Create Web App with local-git deploy
REMOTE_NAME=production
# Set remote on src
printf "\nSetting Git remote...(5/7)\n\n"
git remote add $REMOTE_NAME $GIT_URL
printf "\nGit add...(6/7)\n\n"
git add .
git commit -m "initial revision"
printf "\nGit push... (7/7)\n\n"
# printf "When prompted for a password enter this: $DEPLOY_PASSWORD\n"
# git push --set-upstream $REMOTE_NAME master
git push "https://$DEPLOY_USER:$DEPLOY_PASSWORD@$apiappname.scm.azurewebsites.net/$apiappname.git"
printf "Setup complete!\n\n"
printf "*********************** IMPORTANT INFO *********************\n\n"
printf "Swagger URL: https://$apiappname.azurewebsites.net/swagger\n"
printf "Example URL: https://$apiappname.azurewebsites.net/swagger/v1/swagger.json\n\n"