Skip to content

Commit f5a3174

Browse files
authored
Merge pull request #2 from eggboy/copilot/upgrade-versions
Upgrade JDK to 21, Spring Boot to 3.5.13, Spring Cloud to 2025.0.2
2 parents fd842e3 + d1f8c60 commit f5a3174

6 files changed

Lines changed: 141 additions & 14 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ jobs:
4040

4141
steps:
4242
- name: Checkout repository
43-
uses: actions/checkout@v3
44-
- uses: actions/setup-java@v1
43+
uses: actions/checkout@v4
44+
- uses: actions/setup-java@v4
4545
with:
46-
java-version: 17
46+
java-version: 21
47+
distribution: temurin
4748
# Initializes the CodeQL tools for scanning.
4849
- name: Initialize CodeQL
49-
uses: github/codeql-action/init@v2
50+
uses: github/codeql-action/init@v3
5051
with:
5152
languages: ${{ matrix.language }}
5253
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -60,7 +61,7 @@ jobs:
6061
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
6162
# If this step fails, then you should remove it and run the build manually (see below)
6263
- name: Autobuild
63-
uses: github/codeql-action/autobuild@v2
64+
uses: github/codeql-action/autobuild@v3
6465

6566
# ℹ️ Command-line programs to run using the OS shell.
6667
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -73,6 +74,6 @@ jobs:
7374
# ./location_of_script_within_repo/buildscript.sh
7475

7576
- name: Perform CodeQL Analysis
76-
uses: github/codeql-action/analyze@v2
77+
uses: github/codeql-action/analyze@v3
7778
with:
7879
category: "/language:${{matrix.language}}"

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,8 @@ build/
3131

3232
### VS Code ###
3333
.vscode/
34+
35+
### Azure Functions ###
36+
local.settings.json
37+
obj/
38+
bin/

README.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
11
[![CodeQL](https://github.com/eggboy/springcloud-azurefunction/actions/workflows/codeql.yml/badge.svg)](https://github.com/eggboy/springcloud-azurefunction/actions/workflows/codeql.yml)
22
# springcloud-azurefunction
3-
Azure Function built with Spring Cloud Function in Java 17
3+
Azure Function built with Spring Cloud Function in Java 21
4+
5+
## Prerequisites
6+
7+
- JDK 21
8+
- Maven
9+
- [Azure Functions Core Tools](https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local) v4+
10+
11+
## Build
12+
13+
```shell
14+
mvn clean package
15+
```
16+
17+
## Run Locally
18+
19+
```shell
20+
mvn azure-functions:run
21+
```
22+
23+
Then use `curl` to interact with the REST API:
24+
25+
```shell
26+
# Create a user
27+
curl -X POST -H 'Content-Type:application/json' http://localhost:7072/api/AzureWebAdapter/user -d '{"userId":"1","lastName":"Doe","firstName":"John","email":"john@example.com"}'
28+
29+
# Get a user
30+
curl -X GET http://localhost:7072/api/AzureWebAdapter/user/1
31+
```
32+
33+
## Deploy to Azure
34+
35+
```shell
36+
az login
37+
mvn azure-functions:deploy -Pdeploy
38+
```
39+
40+
You can override the default Azure resource settings with `-D` flags:
41+
42+
```shell
43+
mvn azure-functions:deploy -Pdeploy \
44+
-DfunctionAppName=my-app \
45+
-DfunctionAppRegion=westus \
46+
-DfunctionResourceGroup=my-resource-group
47+
```

pom.xml

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.7.9</version>
8+
<version>3.5.13</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>io.jaylee</groupId>
@@ -14,8 +14,13 @@
1414
<name>azurefunction</name>
1515
<description>Demo project for Spring Boot</description>
1616
<properties>
17-
<java.version>17</java.version>
18-
<spring-cloud.version>2021.0.5</spring-cloud.version>
17+
<java.version>21</java.version>
18+
<spring-cloud.version>2025.0.2</spring-cloud.version>
19+
<spring-boot-thin-layout.version>1.0.31.RELEASE</spring-boot-thin-layout.version>
20+
<start-class>io.jaylee.springcloud.AzurefunctionApplication</start-class>
21+
<azure.functions.maven.plugin.version>1.41.0</azure.functions.maven.plugin.version>
22+
<!-- Azure resource defaults for local packaging; override with -D flags or the 'deploy' profile -->
23+
<functionAppName>springcloud-azurefunction</functionAppName>
1924
</properties>
2025
<dependencies>
2126
<dependency>
@@ -28,7 +33,7 @@
2833
</dependency>
2934
<dependency>
3035
<groupId>org.springframework.cloud</groupId>
31-
<artifactId>spring-cloud-function-context</artifactId>
36+
<artifactId>spring-cloud-function-adapter-azure-web</artifactId>
3237
</dependency>
3338

3439
<dependency>
@@ -61,6 +66,41 @@
6166

6267
<build>
6368
<plugins>
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-deploy-plugin</artifactId>
72+
<configuration>
73+
<skip>true</skip>
74+
</configuration>
75+
</plugin>
76+
<plugin>
77+
<groupId>com.microsoft.azure</groupId>
78+
<artifactId>azure-functions-maven-plugin</artifactId>
79+
<version>${azure.functions.maven.plugin.version}</version>
80+
<configuration>
81+
<appName>${functionAppName}</appName>
82+
<hostJson>${project.basedir}/src/main/resources/host.json</hostJson>
83+
<runtime>
84+
<os>linux</os>
85+
<javaVersion>21</javaVersion>
86+
</runtime>
87+
<funcPort>7072</funcPort>
88+
<appSettings>
89+
<property>
90+
<name>FUNCTIONS_EXTENSION_VERSION</name>
91+
<value>~4</value>
92+
</property>
93+
</appSettings>
94+
</configuration>
95+
<executions>
96+
<execution>
97+
<id>package-functions</id>
98+
<goals>
99+
<goal>package</goal>
100+
</goals>
101+
</execution>
102+
</executions>
103+
</plugin>
64104
<plugin>
65105
<groupId>org.springframework.boot</groupId>
66106
<artifactId>spring-boot-maven-plugin</artifactId>
@@ -72,8 +112,38 @@
72112
</exclude>
73113
</excludes>
74114
</configuration>
115+
<dependencies>
116+
<dependency>
117+
<groupId>org.springframework.boot.experimental</groupId>
118+
<artifactId>spring-boot-thin-layout</artifactId>
119+
<version>${spring-boot-thin-layout.version}</version>
120+
</dependency>
121+
</dependencies>
75122
</plugin>
76123
</plugins>
77124
</build>
78125

126+
<profiles>
127+
<profile>
128+
<id>deploy</id>
129+
<properties>
130+
<functionAppRegion>koreacentral</functionAppRegion>
131+
<functionResourceGroup>java-functions-group</functionResourceGroup>
132+
</properties>
133+
<build>
134+
<plugins>
135+
<plugin>
136+
<groupId>com.microsoft.azure</groupId>
137+
<artifactId>azure-functions-maven-plugin</artifactId>
138+
<configuration>
139+
<appName>${functionAppName}</appName>
140+
<resourceGroup>${functionResourceGroup}</resourceGroup>
141+
<region>${functionAppRegion}</region>
142+
</configuration>
143+
</plugin>
144+
</plugins>
145+
</build>
146+
</profile>
147+
</profiles>
148+
79149
</project>

src/main/java/io/jaylee/springcloud/model/User.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import lombok.*;
44

5-
import javax.persistence.Entity;
6-
import javax.persistence.Id;
7-
import javax.persistence.Table;
5+
import jakarta.persistence.Entity;
6+
import jakarta.persistence.Id;
7+
import jakarta.persistence.Table;
88
import java.time.ZonedDateTime;
99

1010
@Entity

src/main/resources/host.json

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+
}

0 commit comments

Comments
 (0)