Skip to content

Commit 3fb380a

Browse files
* Working version
1 parent 50ffbbd commit 3fb380a

File tree

4 files changed

+98
-30
lines changed

4 files changed

+98
-30
lines changed

samples/docker/Docker-template.dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ RUN apt-get -qq update \
1515
&& apt-get install -y libfreetype6 fontconfig fonts-dejavu \
1616
&& rm -rf /var/lib/apt/lists/*
1717

18+
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash && \
19+
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg && \
20+
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg && \
21+
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/debian/$(lsb_release -rs | cut -d'.' -f 1)/prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list' && \
22+
apt-get update && \
23+
apt-get install azure-functions-core-tools-4
24+
1825
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
1926
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_MAVEN_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
2027
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
@@ -31,10 +38,10 @@ ENV MAVEN_HOME=/usr/share/maven
3138
ENV MAVEN_CONFIG="$USER_HOME_DIR/.m2"
3239
ENV JAVA_HOME=${JAVA_HOME}
3340
#Java installation complete
34-
RUN apt-get update && apt-get install --no-install-recommends -y python3.9 python3.9-dev python3.9-venv python3-pip python3-wheel build-essential && \
41+
RUN apt-get update && apt-get install --no-install-recommends -y python3.11 python3.11-dev python3.11-venv python3-pip python3-wheel build-essential && \
3542
apt-get clean && rm -rf /var/lib/apt/lists/*
3643
# create and activate virtual environment
37-
RUN python3.9 -m venv /opt/venv
44+
RUN python3.11 -m venv /opt/venv
3845
ENV PATH="/opt/venv/bin:$PATH"
3946
#Python installation complete
4047
COPY ./samples/docker/host.json /src/host.json

samples/docker/init-functions.sh

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
11
#!/bin/bash
22
echo "Entering entry point"
33
cd /src/
4+
45
ExtensionBundlePath=$(func GetExtensionBundlePath)
56
BundlePath="/src/Microsoft.Azure.Functions.ExtensionBundle.zip"
67
if [ -f "$BundlePath" ]; then
7-
unzip -o $BundlePath -d $ExtensionBundlePath
8+
unzip -o "$BundlePath" -d "$ExtensionBundlePath"
89
fi
9-
cp /src/Microsoft.Azure.WebJobs.Extensions.Kusto.dll $ExtensionBundlePath/bin/Microsoft.Azure.WebJobs.Extensions.Kusto.dll
10+
11+
cp /src/Microsoft.Azure.WebJobs.Extensions.Kusto.dll $ExtensionBundlePath/bin/Microsoft.Azure.WebJobs.Extensions.Kusto.dll
12+
# Register the Kusto extension in extensions.json
13+
EXTENSIONS_JSON="$BUNDLE_BIN/extensions.json"
14+
KUSTO_TYPE="Microsoft.Azure.WebJobs.Kusto.KustoBindingStartup, Microsoft.Azure.WebJobs.Extensions.Kusto, Version=1.1.0.0, Culture=neutral, PublicKeyToken=7e376be80b905e82"
15+
16+
if [ -f "$EXTENSIONS_JSON" ]; then
17+
if ! grep -q "KustoBindingStartup" "$EXTENSIONS_JSON"; then
18+
echo "Registering Kusto extension in extensions.json"
19+
# Find the max existing name number and add 1
20+
MAX_NUM=$(grep -oP '"name":\s*"Startup\K\d+' "$EXTENSIONS_JSON" | sort -n | tail -1)
21+
NEXT_NUM=$(( ${MAX_NUM:-0} + 1 ))
22+
# Insert new extension entry before the closing array bracket
23+
sed -i "s|}\s*]|},\n { \"name\": \"Startup${NEXT_NUM}\", \"typeName\": \"${KUSTO_TYPE}\" }\n ]|" "$EXTENSIONS_JSON"
24+
else
25+
echo "Kusto extension already registered in extensions.json"
26+
fi
27+
else
28+
echo "Creating extensions.json with Kusto extension"
29+
cat > "$EXTENSIONS_JSON" << EJSON
30+
{
31+
"extensions": [
32+
{ "name": "Startup", "typeName": "${KUSTO_TYPE}" }
33+
]
34+
}
35+
EJSON
36+
fi
37+
38+
echo "Extension bundle path: $ExtensionBundlePath"
39+
echo "Init complete"

samples/docker/start-functions.sh

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,60 @@
11
#!/bin/bash
2-
# Takes 3 parameters the path to navigate to , the language and the port to run the func tools on
3-
while getopts l:p: flag
4-
do
5-
case "${flag}" in
6-
l) language=${OPTARG};;
7-
p) port=${OPTARG};;
8-
esac
2+
# Starts Azure Functions for a given language sample
3+
# Usage: start-functions.sh -l <language> -p <port>
4+
5+
while getopts l:p: flag; do
6+
case "${flag}" in
7+
l) language=${OPTARG} ;;
8+
p) port=${OPTARG} ;;
9+
esac
910
done
11+
12+
if [ -z "${language:-}" ] || [ -z "${port:-}" ]; then
13+
echo "Usage: start-functions.sh -l <language> -p <port>"
14+
exit 1
15+
fi
16+
1017
echo "Using language: $language & Port: $port"
1118
echo "Running $language functions samples"
12-
cd /src/samples-$language
13-
if [ $language == "outofproc" ]; then
14-
echo "Changing language to c-sharp for out of process worker"
15-
cd bin/Debug/net8.0
16-
func start --csharp --verbose --port $port >> func-logs.txt &
17-
# Added this as a seperate clause just in case we want to have this independent from OutOfProcess worker
18-
elif [ $language == "csharp" ]; then
19-
echo "Changing language to c-sharp for out of process worker"
20-
cd bin/Debug/net8.0
21-
func start --csharp --verbose --port $port >> func-logs.txt &
22-
else
23-
# the compiled functions are in this location
24-
if [[ $language == "java" ]]; then
25-
echo "Changing to Java functions directory"
26-
cd target/azure-functions/kustojavafunctionssample-20230130111810292
27-
fi
28-
func start --$language --verbose --port $port >> func-logs.txt &
29-
fi
19+
20+
SAMPLES_DIR="/src/samples-${language}"
21+
if [ ! -d "$SAMPLES_DIR" ]; then
22+
echo "Error: Samples directory $SAMPLES_DIR not found"
23+
exit 1
24+
fi
25+
26+
cd "$SAMPLES_DIR"
27+
28+
case "$language" in
29+
outofproc)
30+
echo "Starting out-of-process dotnet-isolated worker"
31+
cd bin/Debug/net8.0
32+
func start --dotnet-isolated --verbose --port "$port" >> func-logs.txt &
33+
;;
34+
csharp)
35+
echo "Starting C# in-process worker"
36+
cd bin/Debug/net8.0
37+
func start --csharp --verbose --port "$port" >> func-logs.txt &
38+
;;
39+
node)
40+
echo "Starting Node.js (JavaScript) worker"
41+
func start --javascript --verbose --port "$port" >> func-logs.txt &
42+
;;
43+
java)
44+
echo "Starting Java worker"
45+
cd target/azure-functions/kustojavafunctionssample-20230130111810292
46+
func start --java --verbose --port "$port" >> func-logs.txt &
47+
;;
48+
python)
49+
echo "Starting Python worker"
50+
func start --python --verbose --port "$port" >> func-logs.txt &
51+
;;
52+
powershell)
53+
echo "Starting PowerShell worker"
54+
func start --powershell --verbose --port "$port" >> func-logs.txt &
55+
;;
56+
*)
57+
echo "Error: Unsupported language '$language'"
58+
exit 1
59+
;;
60+
esac

scripts/build-docker-image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ while [[ $# -gt 0 ]]; do
2727
esac
2828
done
2929

30-
BASE_IMAGE_TAG="node:4-node20-core-tools"
30+
BASE_IMAGE_TAG="node:4-node22"
3131
TARGET_IMAGE_NAME="func-az-kusto-base"
3232
BUILD_DATE=$(date +"%Y%m%d")
3333
TARGET_FILE_LOCATION="./samples/docker"

0 commit comments

Comments
 (0)