forked from coralogix/coralogix-azure-serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (77 loc) · 3.3 KB
/
Makefile
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Configurable exports
export AZURE_REGION ?= westeurope
export CORALOGIX_APP_NAME ?= Azure
export CORALOGIX_SUB_SYSTEM ?= "BlobViaEventGrid"
export NEWLINE_PATTERN ?= (?:\r\n|\r|\n)
# Cluster API Endpoint
# .com https://api.coralogix.com:443/api/v1/logs
# .us https://api.coralogix.us:443/api/v1/logs
# .in https://api.app.coralogix.in:443/api/v1/logs
# .app.eu2.coralogix.com https://api.eu2.coralogix.com:443/api/v1/logs
# .app.coralogixsg.com https://api.coralogixsg.com:443/api/v1/logs
export CORALOGIX_URL ?= "https://api.coralogix.com:443/api/v1/logs"
# Fixed exports
export AZURE_RESOURCE_GROUP ?= CrlgxRG$(UUID)
export AZURE_FUNCTION_NAME ?= blobfunc$(UUID)
export AZURE_FUNCTION_STORAGE_ACCOUNT ?= storage$(UUID)
functools:
@echo "Will now install: azure-functions-core-tools v4 "
@npm install -g azure-functions-core-tools@4 --unsafe-perm true
dependencies:
@echo "Will now build the dependencies"
@npm install
build: dependencies
@echo "Will now build the application with npm"
@npm run build:production
clean:
@echo "Will now cleanup dist folder"
@rm -rf dist
install:
@echo "Creating Resource Group $(AZURE_RESOURCE_GROUP) in Region: $(AZURE_REGION)"
@az group create \
--name $(AZURE_RESOURCE_GROUP) \
--location $(AZURE_REGION)
@echo "Creating Storage Account $(AZURE_FUNCTION_STORAGE_ACCOUNT) in Region: $(AZURE_REGION)"
@echo "Will be included in RG: $(AZURE_RESOURCE_GROUP) and have Standard LRS redundency"
az storage account create \
--name "$(AZURE_FUNCTION_STORAGE_ACCOUNT)" \
--location $(AZURE_REGION) \
--resource-group $(AZURE_RESOURCE_GROUP) \
--sku Standard_LRS
@echo "Will now create the function with the following parameters"
@echo "Function Name: $(AZURE_FUNCTION_NAME)"
@echo "Resource Group: $(AZURE_RESOURCE_GROUP)"
@echo "Consumption Plan Location: $(AZURE_REGION)"
@echo "Runtime: node Version: 16"
@echo "Functions Version: 4"
@echo "Storage-account $(AZURE_FUNCTION_STORAGE_ACCOUNT)"
az functionapp create \
--name $(AZURE_FUNCTION_NAME) \
--resource-group $(AZURE_RESOURCE_GROUP) \
--consumption-plan-location $(AZURE_REGION) \
--runtime node \
--runtime-version 16 \
--functions-version 4 \
--storage-account $(AZURE_FUNCTION_STORAGE_ACCOUNT)
configure:
@echo "Configuring the Function Environment"
@echo "CORALOGIX_PRIVATE_KEY=$(CORALOGIX_PRIVATE_KEY)"
@echo "CORALOGIX_APP_NAME=$(CORALOGIX_APP_NAME)"
@echo "CORALOGIX_SUB_SYSTEM=$(CORALOGIX_SUB_SYSTEM)"
@echo "NEWLINE_PATTERN=$(NEWLINE_PATTERN)"
@echo "BLOB_STORAGE_ACCOUNT_CONNECTION_STRING=$(BLOB_STORAGE_ACCOUNT_CONNECTION_STRING)"
@echo "CORALOGIX_URL=$(CORALOGIX_URL)"
az functionapp config appsettings set \
--name $(AZURE_FUNCTION_NAME) \
--resource-group $(AZURE_RESOURCE_GROUP) \
--settings "CORALOGIX_PRIVATE_KEY=$(CORALOGIX_PRIVATE_KEY)" \
"CORALOGIX_APP_NAME=$(CORALOGIX_APP_NAME)" \
"CORALOGIX_SUB_SYSTEM=$(CORALOGIX_SUB_SYSTEM)" \
"NEWLINE_PATTERN=$(NEWLINE_PATTERN)" \
"BLOB_STORAGE_ACCOUNT_CONNECTION_STRING=$(BLOB_STORAGE_ACCOUNT_CONNECTION_STRING)" \
"CORALOGIX_URL=$(CORALOGIX_URL)"
publish: build
@echo "Will now publish the function we created"
func azure functionapp publish $(AZURE_FUNCTION_NAME) --typescript
deploy: install configure publish
all: functools clean install configure publish