🇩🇪 Dieses Repository enthält den Source Code hinter den Websites:
- markt.lokations.id, einem Generator für Marktlokations-IDs ("MaLo-ID") zu Testzwecken
- netz.lokations.id, einem Generator für Netzlokations-IDs ("NeLo-ID") zu Testzwecken
- mess.lokations.id, einem Generator für Messlokations-IDs ("MeLo-ID") zu Testzwecken
- technische.ressource.id, einem Generator für Technische Ressourcen-IDs ("TR-ID") zu Testzwecken
- steuerbare.ressource.id, einem Generator für Steuerbare Ressourcen-IDs ("SR-ID") zu Testzwecken
🇬🇧 This repository contains an Azure Function with a Go Handler which is deployed to netz.lokations.id and markt.lokations.id.
Its purpose is to
- generate:
- Marktlokations-IDs (MaLo-IDs)
- Netzlokations-IDs (NeLo-IDs)
- Messlokations-IDs (MeLo-IDs)
- Technische Ressourcen-IDs (TR-IDs)
- Steuerbare Ressourcen-IDs (SR-IDs)
- with a valid checksum
- on the fly
The business logic is written in Go using Gin Gonic and can be found in cmd/api.go.
It's a super basic website with three "pseudo files":
/
(root) that returns a basic HTML site which refers to (this is the main entry point for users)/api/favicon
(returns a favicon) and refers to/api/style
(returns a stylesheet)
The files are not really served as plain files as you would expect it from a usual web app setup, but they are all separate Azure Functions and hence have their own respective function.json
.
The files are embedded into the go binary using go:embed
.
This means you need to rebuild in order to change e.g. the stylesheet.
The setup is generally described quite well in this article by Thorsten Hans.
First install the Azure Function Core Tools.
Then, in the root directory of this repo, execute:
go build -o api ./cmd/
followed by (also in the repo root)
func start
This function app is managed in two separate Azure Function Apps.
Both Function apps are assigned to the malo-id-generator resource group on Azure.
There is one function app instance per supported ID type.
This is because to use the function app directly behind top level domain registered in Azure, its respective entry point must be a top level domain itself without any further, relative path (e.g. foobarsomerandomstring.azurewebsites.net
and not foobarsomerandomstring.azurewebsites.net/malo
).
Purpose | ID_TYPE_TO_GENERATE env var value |
Deployed to (URL) | Settings |
---|---|---|---|
Generate MaLo-IDs | "MALO" |
malo-id-generator.azurewebsites.net/ and markt.lokations.id |
malo-id-generator |
Generate NeLo-IDs | "NELO" |
nelo-id-generator.azurewebsites.net/ and netz.lokations.id |
nelo-id-generator |
Generate MeLo-IDs | "MELO" |
melo-id-generator.azurewebsites.net/ and mess.lokations.id |
melo-id-generator |
Generate TR-IDs | "TRID" |
tr-id-generator.azurewebsites.net/ and technische.ressource.id |
tr-id-generator |
Generate SR-IDs | "SRID" |
sr-id-generator.azurewebsites.net/ and steuerbare.ressource.id |
sr-id-generator |
The function apps are all
- code based (instead of dockerized (todo @kevin))
- linux based (instead of windows)
There is an environment variable named ID_TYPE_TO_GENERATE
which you can modify in the function app settings.
Its value can be "MALO"
or "NELO"
or "MELO"
or "TRID"
or "SRID"
at the moment.
If its value is not set or set to an invalid value, the function app will return a HTTP 501 error.
For your local tests you can modify the value in the local.settings.json
file.
There is no automatic deployment yet (fixable with docker).
To deploy:
First build locally for linux (note that the build is the same for all ID types, only the env var is different)
set GOOS=linux
go build -o api ./cmd
The GOOS env var can be set in the build configuration in Goland.
The build should create an api
(no file ending) file on root level.
Then upload
func azure functionapp publish malo-id-generator
or
func azure functionapp publish nelo-id-generator
respectively (and similar for melo-id-generator
, sr-id-generator
and tr-id-generator
).
You have to be logged in (az login
) using the Azure CLI Tools.
func azure functionapp publish malo-id-generator
func azure functionapp publish melo-id-generator
func azure functionapp publish nelo-id-generator
func azure functionapp publish sr-id-generator
func azure functionapp publish tr-id-generator