Skip to content

Commit 626405e

Browse files
authored
Merge branch 'dev' into auto-update-jdk-versions
2 parents 2717b0c + eedba9e commit 626405e

23 files changed

Lines changed: 468 additions & 78 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,6 @@ __pycache__/
288288

289289
# Environment configuration files
290290
.env
291+
292+
# Docker test packages
293+
dockertests/app-packages/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"version": "2.0",
3+
"extensionBundle": {
4+
"id": "Microsoft.Azure.Functions.ExtensionBundle",
5+
"version": "[4.*, 5.0.0)"
6+
}
7+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.microsoft.azure.samples</groupId>
8+
<artifactId>timezone-check</artifactId>
9+
<version>1.0.0</version>
10+
<packaging>jar</packaging>
11+
12+
<name>Azure Functions Java Timezone Check</name>
13+
<description>Simple HTTP trigger that returns the current timezone</description>
14+
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<java.version>8</java.version>
18+
<maven.compiler.source>8</maven.compiler.source>
19+
<maven.compiler.target>8</maven.compiler.target>
20+
<azure.functions.maven.plugin.version>1.39.0</azure.functions.maven.plugin.version>
21+
<azure.functions.java.library.version>3.2.2</azure.functions.java.library.version>
22+
<functionAppName>timezone-check</functionAppName>
23+
</properties>
24+
25+
<dependencies>
26+
<dependency>
27+
<groupId>com.microsoft.azure.functions</groupId>
28+
<artifactId>azure-functions-java-library</artifactId>
29+
<version>${azure.functions.java.library.version}</version>
30+
</dependency>
31+
</dependencies>
32+
33+
<build>
34+
<plugins>
35+
<plugin>
36+
<groupId>org.apache.maven.plugins</groupId>
37+
<artifactId>maven-compiler-plugin</artifactId>
38+
<version>3.14.0</version>
39+
<configuration>
40+
<source>${java.version}</source>
41+
<target>${java.version}</target>
42+
</configuration>
43+
</plugin>
44+
<plugin>
45+
<groupId>com.microsoft.azure</groupId>
46+
<artifactId>azure-functions-maven-plugin</artifactId>
47+
<version>${azure.functions.maven.plugin.version}</version>
48+
<configuration>
49+
<appName>timezone-check</appName>
50+
<resourceGroup>rg-functions-quickstart-java</resourceGroup>
51+
<region>eastus</region>
52+
<runtime>
53+
<os>linux</os>
54+
<javaVersion>17</javaVersion>
55+
</runtime>
56+
<appSettings>
57+
<property>
58+
<name>FUNCTIONS_EXTENSION_VERSION</name>
59+
<value>~4</value>
60+
</property>
61+
</appSettings>
62+
</configuration>
63+
<executions>
64+
<execution>
65+
<id>package-functions</id>
66+
<goals>
67+
<goal>package</goal>
68+
</goals>
69+
</execution>
70+
</executions>
71+
</plugin>
72+
</plugins>
73+
</build>
74+
</project>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.microsoft.azure.samples;
2+
3+
import com.microsoft.azure.functions.annotation.*;
4+
import com.microsoft.azure.functions.*;
5+
6+
import java.util.TimeZone;
7+
8+
/**
9+
* Azure Functions HTTP Trigger that returns the current timezone information.
10+
* This function is used to verify that the TZ environment variable is correctly
11+
* applied to the Java runtime.
12+
*/
13+
public class TimezoneFunction {
14+
15+
@FunctionName("GetTimezone")
16+
public HttpResponseMessage run(
17+
@HttpTrigger(
18+
name = "req",
19+
methods = {HttpMethod.GET},
20+
authLevel = AuthorizationLevel.ANONYMOUS
21+
) HttpRequestMessage<String> request,
22+
final ExecutionContext context) {
23+
24+
context.getLogger().info("Processing timezone request.");
25+
26+
// Get the default timezone
27+
TimeZone defaultTimezone = TimeZone.getDefault();
28+
String timezoneId = defaultTimezone.getID();
29+
String tzEnvVar = System.getenv("TZ");
30+
31+
context.getLogger().info(String.format("Default timezone ID: %s, TZ env var: %s",
32+
timezoneId, tzEnvVar != null ? tzEnvVar : "not set"));
33+
34+
// Return the timezone ID
35+
return request.createResponseBuilder(HttpStatus.OK)
36+
.header("Content-Type", "text/plain")
37+
.body(timezoneId)
38+
.build();
39+
}
40+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "azure-functions-test-kit"
7+
version = "0.1.0"
8+
description = "Reusable test kit for Azure Functions workers"
9+
requires-python = ">=3.8"
10+
dependencies = [
11+
"pytest>=7.0",
12+
"pytest-xdist>=3.0",
13+
"azure-storage-blob>=12.19.0",
14+
"requests>=2.31.0",
15+
"cryptography>=41.0.0",
16+
"python-dotenv>=1.0.0",
17+
"pyjwt>=2.8.0"
18+
]
19+
20+
[project.entry-points.pytest11]
21+
azure_functions_test_kit = "azure_functions_test_kit.plugin"
22+
23+
[tool.hatch.build.targets.wheel]
24+
packages = ["src/azure_functions_test_kit"]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
"""
4+
Azure Functions Test Kit - Testing utilities for Azure Functions.
5+
6+
Usage:
7+
from azure_functions_test_kit import LinuxConsumptionTestEnvironment
8+
9+
@pytest.fixture
10+
def test_env():
11+
with LinuxConsumptionTestEnvironment(apps_to_upload=['MyApp']) as env:
12+
yield env
13+
"""
14+
15+
__version__ = "0.1.0"
16+
17+
# Export main classes for easy import
18+
from .controllers.azurite_container_controller import AzuriteContainerController
19+
from .controllers.functions_container_controller import FunctionsContainerController
20+
from .environments.consumption import LinuxConsumptionTestEnvironment
21+
22+
__all__ = [
23+
"AzuriteContainerController",
24+
"FunctionsContainerController",
25+
"LinuxConsumptionTestEnvironment"
26+
]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .azurite_container_controller import AzuriteContainerController
2+
from .functions_container_controller import FunctionsContainerController

dockertests/utils/azurite_container_controller.py renamed to dockertests/azure-functions-test-kit/src/azure_functions_test_kit/controllers/azurite_container_controller.py

File renamed without changes.

dockertests/utils/functions_container_controller.py renamed to dockertests/azure-functions-test-kit/src/azure_functions_test_kit/controllers/functions_container_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,4 +613,4 @@ def __exit__(self, exc_type, exc_value, traceback):
613613
if traceback:
614614
print(f'❌ Test failed with container logs:\n{logs}',
615615
file=sys.stderr,
616-
flush=True)
616+
flush=True)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .consumption import LinuxConsumptionTestEnvironment

0 commit comments

Comments
 (0)