Skip to content
This repository was archived by the owner on Oct 14, 2023. It is now read-only.

Commit 6494c0d

Browse files
author
Yoichi Kawasaki
committed
Refactors helper scripts
1 parent 64f8821 commit 6494c0d

File tree

7 files changed

+114
-20
lines changed

7 files changed

+114
-20
lines changed

scripts/create-azfunc-v2-linux-app-service-plan.sh

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,12 @@ REGION="<REGION NAME: eastus>"
99
STORAGE_ACCOUNT="<STORAGE ACCOUNT NAME>"
1010
PLAN_NAME="<APP SERVICE PLAN NAME>"
1111
APP_NAME="<FUNCTION APP NAME>" # the name needs to be unique across all apps in Azure.
12-
# [NOTE]
13-
# Linux Consumption plan is only available in limited regions
14-
# see https://github.com/Azure/Azure-Functions/wiki/Azure-Functions-on-Linux-Preview#prerequisites
15-
16-
echo "Create Resource Group: $RESOURCE_GROUP"
17-
az group create --name $RESOURCE_GROUP --location $REGION
1812

1913
echo "Create App Service Plan"
2014
az appservice plan create --name $PLAN_NAME \
2115
--resource-group $RESOURCE_GROUP \
2216
--sku B1 --is-linux
2317

24-
echo "Create an Azure Storage account: $STORAGE_ACCOUNT"
25-
az storage account create --name $STORAGE_ACCOUNT \
26-
--location $REGION \
27-
--resource-group $RESOURCE_GROUP \
28-
--sku Standard_LRS
29-
3018
echo "Create a empty function app on Linux (App Service Plan): $APP_NAME"
3119
az functionapp create \
3220
--resource-group $RESOURCE_GROUP \

scripts/create-azfunc-v2-linux-consumption-plan.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@ APP_NAME="<FUNCTION APP NAME>" # the name needs to be unique across all apps in
1212
# Linux Consumption plan is only available in limited regions
1313
# see https://github.com/Azure/Azure-Functions/wiki/Azure-Functions-on-Linux-Preview#prerequisites
1414

15-
echo "Create Resource Group: $RESOURCE_GROUP"
16-
az group create --name $RESOURCE_GROUP --location $REGION
17-
18-
echo "Create an Azure Storage account: $STORAGE_ACCOUNT"
19-
az storage account create --name $STORAGE_ACCOUNT \
20-
--location $REGION \
21-
--resource-group $RESOURCE_GROUP \
22-
--sku Standard_LRS
15+
RESOURCE_GROUP="RG-azfuncv2-t"
16+
REGION="westus"
17+
STORAGE_ACCOUNT="azfuncv2linuxstore2"
18+
APP_NAME="yoichikaazfuncv2linux002" # the name needs to be unique across all apps in Azure.
2319

2420
echo "Create a empty function app on Linux (Consumption Plan): $APP_NAME"
2521
az functionapp create \

scripts/create-resource-group.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
set -e -x
3+
# Create Azure Resource group
4+
5+
RESOURCE_GROUP="<RESOURCE GROUPP MAME>"
6+
REGION="<REGION NAME: eastus>"
7+
8+
RESOURCE_GROUP="RG-azfuncv2-ta"
9+
REGION="japanwest"
10+
11+
echo "Create Resource Group: $RESOURCE_GROUP"
12+
az group create --name $RESOURCE_GROUP --location $REGION
13+
14+
echo "Done"

scripts/create-storage-account.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
set -e -x
3+
# Create Azure Storage Account
4+
5+
RESOURCE_GROUP="<RESOURCE GROUPP MAME>"
6+
REGION="<REGION NAME: eastus>"
7+
STORAGE_ACCOUNT="<STORAGE ACCOUNT NAME>"
8+
9+
RESOURCE_GROUP="RG-azfuncv2-ta"
10+
REGION="japanwest"
11+
STORAGE_ACCOUNT="azfuncv2linuxstore3"
12+
13+
echo "Create an Azure Storage account: $STORAGE_ACCOUNT"
14+
az storage account create --name $STORAGE_ACCOUNT \
15+
--location $REGION \
16+
--resource-group $RESOURCE_GROUP \
17+
--sku Standard_LRS
18+
19+
echo "Done"

scripts/docker-build.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
set -e -x
3+
4+
cwd=`dirname "$0"`
5+
expr "$0" : "/.*" > /dev/null || cwd=`(cd "$cwd" && pwd)`
6+
7+
DOCKER_ID="<Your Docker ID>"
8+
CONTAINER_IMAGE_NAME="<Container Image Name: azfuncpythonsamples>"
9+
10+
FUNC_PROJECT_DIR="$cwd/../v2functions"
11+
12+
cd $FUNC_PROJECT_DIR
13+
TAG=`cat VERSION`
14+
docker build --tag $DOCKER_ID/$CONTAINER_IMAGE_NAME:$TAG .

scripts/docker-run-mini.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
set -e -x
3+
4+
cwd=`dirname "$0"`
5+
expr "$0" : "/.*" > /dev/null || cwd=`(cd "$cwd" && pwd)`
6+
7+
#############################################################
8+
# params
9+
#############################################################
10+
DOCKER_ID="<Docker ID>"
11+
CONTAINER_IMAGE_NAME="<Container Image Name>"
12+
#############################################################
13+
14+
FUNC_PROJECT_DIR="$cwd/../v2functions"
15+
16+
TAG=`cat $FUNC_PROJECT_DIR/VERSION`
17+
18+
STORAGE_CONNECTION_STRING=$(az storage account show-connection-string \
19+
--resource-group $RESOURCE_GROUP --name $STORAGE_ACCOUNT_NAME \
20+
--query connectionString --output tsv)
21+
22+
docker run -p 8080:80 -it \
23+
-e AzureWebJobsStorage="$STORAGE_CONNECTION_STRING" \
24+
-e MyStorageConnectionString="$STORAGE_CONNECTION_STRING"
25+
$DOCKER_ID/$CONTAINER_IMAGE_NAME:$TAG

scripts/docker-run.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/sh
2+
set -e -x
3+
4+
cwd=`dirname "$0"`
5+
expr "$0" : "/.*" > /dev/null || cwd=`(cd "$cwd" && pwd)`
6+
7+
#############################################################
8+
# params
9+
#############################################################
10+
DOCKER_ID="<Docker ID>"
11+
CONTAINER_IMAGE_NAME="<Container Image Name>"
12+
RESOURCE_GROUP="<RESOURCE GROUPP MAME>"
13+
REGION="<REGION NAME: eastus>"
14+
STORAGE_ACCOUNT_NAME="<STORAGE ACCOUNT NAME>"
15+
COSMOSDB_ACCOUNT_NAME="<COSMOSDB ACCOUNT NAME>"
16+
COMPUTER_VSION_API_SUBSCRIPTION="<COMPUTER VISION API SUBSCRIPTION>"
17+
COMPUTER_VSION_API_ENDPOINT="<COMPUTER VSION API ENDPOINT>"
18+
## example: COMPUTER_VSION_API_ENDPOINT="https://westus.api.cognitive.microsoft.com/"
19+
#############################################################
20+
21+
FUNC_PROJECT_DIR="$cwd/../v2functions.working"
22+
23+
TAG=`cat $FUNC_PROJECT_DIR/VERSION`
24+
25+
STORAGE_CONNECTION_STRING=$(az storage account show-connection-string \
26+
--resource-group $RESOURCE_GROUP --name $STORAGE_ACCOUNT_NAME \
27+
--query connectionString --output tsv)
28+
COSMOSDB_CONNECTION_STRING=$(az cosmosdb list-connection-strings \
29+
--resource-group $RESOURCE_GROUP --name $COSMOSDB_ACCOUNT_NAME \
30+
--query connectionStrings --output tsv | head -1 | awk '{print $1}')
31+
32+
docker run -p 8080:80 -it \
33+
-e AzureWebJobsStorage="$STORAGE_CONNECTION_STRING" \
34+
-e MyStorageConnectionString="$STORAGE_CONNECTION_STRING" \
35+
-e MyCosmosDBConnectionString="$COSMOSDB_CONNECTION_STRING" \
36+
-e ComputerVisionSubscription="$COMPUTER_VSION_API_SUBSCRIPTION" \
37+
-e ComputerVisionApiEndpoint="$COMPUTER_VSION_API_ENDPOINT" \
38+
$DOCKER_ID/$CONTAINER_IMAGE_NAME:$TAG

0 commit comments

Comments
 (0)