Skip to content

Commit d99b2a7

Browse files
committed
Incorporated OIDC for authenticating towards Azure in GH Action
1 parent b5e7cc3 commit d99b2a7

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

hvalfangst_function/function_app.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import logging
2-
import json
3-
import os
4-
import jwt
5-
import pandas as pd
62
import azure.functions as func
7-
from io import StringIO
8-
from sklearn.preprocessing import LabelEncoder
93

104
# Decree and declare our project as an Azure Function App subsidiary
115
app = func.FunctionApp()
@@ -19,6 +13,11 @@
1913
@app.blob_output(arg_name="outbound", path="hvalfangstcontainer/out/statistics.json", connection="")
2014
def blob_trigger(inbound: func.InputStream, outbound: func.Out[str]):
2115
try:
16+
import json
17+
import pandas as pd
18+
from io import StringIO
19+
from sklearn.preprocessing import LabelEncoder
20+
2221
logging.info("Triggered blob function with blob: %s", inbound.name)
2322

2423
# Read CSV content from the blob
@@ -64,6 +63,7 @@ def blob_trigger(inbound: func.InputStream, outbound: func.Out[str]):
6463

6564
def validate_jwt(token: str, audience: str) -> bool:
6665
try:
66+
import jwt
6767
decoded = jwt.decode(token, audience=audience, options={"verify_signature": False})
6868
# Optionally check claims like roles or scopes
6969
return True
@@ -76,6 +76,8 @@ def validate_jwt(token: str, audience: str) -> bool:
7676
@app.blob_output(arg_name="outbound", path="hvalfangstcontainer/in/input.csv", connection="")
7777
def upload_csv(req: func.HttpRequest, outbound: func.Out[str]) -> str:
7878
try:
79+
import jwt
80+
import os
7981
logging.info("Received HTTP request to upload CSV")
8082

8183
# Validate JWT token
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
azure-functions==1.7.0
1+
azure-functions==1.17.0
22
pandas~=2.1.4
3-
scikit-learn~=1.3.2
3+
scikit-learn~=1.3.2
4+
pyjwt==2.9.0

0 commit comments

Comments
 (0)