Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
500e907
add java assets as-is
weikanglim Sep 8, 2022
ebbbc2d
local deployment changes
weikanglim Sep 12, 2022
69dab16
Switch to AZURE_COSMOS_CONNECTION_STRING
weikanglim Sep 12, 2022
fffb639
add ci mention
weikanglim Sep 12, 2022
49889eb
Add java template
weikanglim Sep 12, 2022
3a09bf3
remove openapi
weikanglim Sep 12, 2022
a377982
Project code changes
weikanglim Sep 12, 2022
5c9490a
Add KeyVault and appinsights
weikanglim Sep 13, 2022
81e019d
remove @
weikanglim Sep 13, 2022
af5fc31
Template fixes
weikanglim Sep 14, 2022
cb2df18
Bump up API container to 1 core, 2 GB minimum
weikanglim Sep 15, 2022
c400a80
Fix local development
weikanglim Sep 15, 2022
99a1568
Just mvnw
weikanglim Sep 15, 2022
849fdd5
Add .devcontainer
weikanglim Sep 15, 2022
346c834
Fix appinsights role name
weikanglim Sep 15, 2022
ca8492d
openapi support
weikanglim Sep 15, 2022
d8637bf
Clean up properties and readme
weikanglim Sep 15, 2022
8e36fce
refactor and test
weikanglim Sep 17, 2022
842e303
javac tests
weikanglim Sep 19, 2022
8cf9393
javac tests
weikanglim Sep 19, 2022
5d1f65d
add maven tests
weikanglim Sep 19, 2022
ba52001
Merge upstream/main
weikanglim Sep 19, 2022
afc5595
Update bicep templates
weikanglim Sep 19, 2022
66c3603
fix service bicep module path
weikanglim Sep 19, 2022
31022b0
Bump CPU and memory
weikanglim Sep 20, 2022
807af99
Include proper packaging support
weikanglim Sep 21, 2022
0e93047
App service java changes
weikanglim Sep 21, 2022
680e42f
update template
weikanglim Sep 22, 2022
8653b52
Fix pagination and send body in Create methods
weikanglim Sep 23, 2022
e46262d
Merge main
weikanglim Sep 28, 2022
d4eb0d4
remove extra newline
weikanglim Sep 29, 2022
2f84cf8
Merge upstream/main
weikanglim Sep 30, 2022
49269f2
Add openapigen
weikanglim Oct 3, 2022
feb544a
Update repo.yaml
weikanglim Oct 3, 2022
495ef8a
Update resources.png
weikanglim Oct 3, 2022
27a9da1
Remove touch
weikanglim Oct 3, 2022
cd8df38
Update cspell
weikanglim Oct 3, 2022
fb76882
Reorder launch.json
weikanglim Oct 3, 2022
dbf6c76
Add back rewrite
weikanglim Oct 3, 2022
12d7faf
Update templates/todo/projects/java-mongo/README.md
weikanglim Oct 4, 2022
df53ebc
Update dockerfile
weikanglim Oct 4, 2022
8408cd7
Update cli-app image
weikanglim Oct 4, 2022
dedbc89
Upgrade dependencies
weikanglim Oct 5, 2022
5e6f642
reorder cleanup
weikanglim Oct 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .vscode/cspell-templates.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,29 @@ autouse
azdo
borderless
browserslist
codegen
codepaths
Codespaces
configfile
configurer
containerapp
CUSTOMHANDLER
databind
Dskip
eastus
envconfig
ezfunc
fasterxml
immer
inprogress
INPROGRESS
Instrumentor
mkdir
mvnw
networkidle
noverify
openapigen
openapitools
OPTARG
prestart
printenv
Expand All @@ -30,6 +39,11 @@ Quickstart
reactd
ROLENAME
Serializers
servlet
simpletodo
simpletodo
springdoc
springframework
staticwebapp
Swashbuckle
tsbuildinfo
Expand Down
2 changes: 2 additions & 0 deletions .vscode/cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ ignorePaths:
- eng # not required
- ext # uses its own cspell config
- "*.bicep" # no need to lint resource files
- mvnw # Maven wrapper asset used in Java templates -- external library code
- mvnw.cmd # Maven wrapper asset used in Java templates -- external library code
dictionaryDefinitions:
- name: templatesDictionary
path: ./cspell-templates.txt
Expand Down
9 changes: 6 additions & 3 deletions cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0
WORKDIR /app

RUN export DEBIAN_FRONTEND=noninteractive \
&& wget -q https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb && dpkg -i packages-microsoft-prod.deb \
&& wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb && dpkg -i packages-microsoft-prod.deb \
&& apt-get update && apt-get install -y --no-install-recommends apt-utils && apt-get install -y apt-transport-https ca-certificates curl unzip procps gnupg2 software-properties-common lsb-release \
# functions core tools
&& curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg \
Expand All @@ -30,7 +30,8 @@ RUN export DEBIAN_FRONTEND=noninteractive \
&& python3 -m pip install --upgrade pip \
&& echo 'alias python=python3' >> ~/.bashrc \
&& echo 'alias pip=pip3' >> ~/.bashrc \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* \
# java
&& apt-get update && apt-get install -y msopenjdk-17 \
# terraform cli
&& apt-get update && apt-get install -y gnupg software-properties-common \
&& wget -O- https://apt.releases.hashicorp.com/gpg | \
Expand All @@ -39,7 +40,9 @@ RUN export DEBIAN_FRONTEND=noninteractive \
&& echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
tee /etc/apt/sources.list.d/hashicorp.list \
&& apt update && apt-get install terraform
&& apt update && apt-get install terraform \
# Cleanup
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

# azd
COPY cli/bin/azd-linux-amd64 /usr/bin/azd
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "Azure Developer CLI",
"build": {
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "bullseye"
}
},
"features": {
"github-cli": "2",
"azure-cli": "2.38",
"docker-from-docker": "20.10",
"java": "17.0",
"node": {
"version": "16",
"nodeGypDependencies": false
}
},
"extensions": [
"ms-azuretools.azure-dev",
"ms-azuretools.vscode-bicep",
"ms-azuretools.vscode-docker",
"ms-vscode.vscode-node-azure-pack",
"vscjava.vscode-java-pack"
],
"forwardPorts": [
3000,
3100
],
"postCreateCommand": "",
"remoteUser": "vscode"
}
35 changes: 35 additions & 0 deletions templates/common/infra/bicep/core/host/appservice-java.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
param environmentName string
param location string = resourceGroup().location

param allowedOrigins array = []
param appCommandLine string = ''
param applicationInsightsName string
param appServicePlanId string
param appSettings object = {}
param keyVaultName string = ''
param linuxFxVersion string = 'JAVA|17-java17'
param managedIdentity bool = !(empty(keyVaultName))
param scmDoBuildDuringDeployment bool = true
param serviceName string

module appService 'appservice.bicep' = {
name: '${serviceName}-appservice-java'
params: {
environmentName: environmentName
location: location
allowedOrigins: allowedOrigins
appCommandLine: appCommandLine
applicationInsightsName: applicationInsightsName
appServicePlanId: appServicePlanId
appSettings: appSettings
keyVaultName: keyVaultName
linuxFxVersion: linuxFxVersion
managedIdentity: managedIdentity
scmDoBuildDuringDeployment: scmDoBuildDuringDeployment
serviceName: serviceName
}
}

output identityPrincipalId string = appService.outputs.identityPrincipalId
output name string = appService.outputs.name
output uri string = appService.outputs.uri
10 changes: 10 additions & 0 deletions templates/common/infra/bicep/core/host/container-app.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ param managedIdentity bool = !(empty(keyVaultName))
param targetPort int = 80
param serviceName string

@description('CPU cores allocated to a single container instance, e.g. 0.5')
param containerCpuCoreCount string = '0.5'

@description('Memory allocated to a single container instance, e.g. 1Gi')
param containerMemory string = '1.0Gi'

var abbrs = loadJsonContent('../../abbreviations.json')
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
var tags = { 'azd-env-name': environmentName }
Expand Down Expand Up @@ -49,6 +55,10 @@ resource app 'Microsoft.App/containerApps@2022-03-01' = {
image: imageName
name: 'main'
env: env
resources: {
cpu: json(containerCpuCoreCount)
memory: containerMemory
}
}
]
}
Expand Down
1 change: 1 addition & 0 deletions templates/todo/api/java/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mvnw text eol=lf
35 changes: 35 additions & 0 deletions templates/todo/api/java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

applicationinsights.log
Binary file not shown.
18 changes: 18 additions & 0 deletions templates/todo/api/java/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
5 changes: 5 additions & 0 deletions templates/todo/api/java/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
src/main/java/com/microsoft/azure/simpletodo/api/ApiUtil.java
src/main/java/com/microsoft/azure/simpletodo/api/ListsApi.java
src/main/java/com/microsoft/azure/simpletodo/model/TodoItem.java
src/main/java/com/microsoft/azure/simpletodo/model/TodoList.java
src/main/java/com/microsoft/azure/simpletodo/model/TodoState.java
1 change: 1 addition & 0 deletions templates/todo/api/java/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.0.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1e0347e24b739d303f3af0493d1e730e4ac47a27fdac1e8a151defcc745496f0
22 changes: 22 additions & 0 deletions templates/todo/api/java/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM mcr.microsoft.com/openjdk/jdk:17-mariner AS build

WORKDIR /workspace/app
EXPOSE 3100

COPY mvnw .
COPY .mvn .mvn
COPY openapi.yaml openapi.yaml
COPY pom.xml .
COPY src src

RUN ./mvnw package -DskipTests
RUN mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar)

FROM mcr.microsoft.com/openjdk/jdk:17-mariner

ARG DEPENDENCY=/workspace/app/target/dependency
COPY --from=build ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY --from=build ${DEPENDENCY}/META-INF /app/META-INF
COPY --from=build ${DEPENDENCY}/BOOT-INF/classes /app

ENTRYPOINT ["java","-noverify", "-XX:MaxRAMPercentage=70", "-XX:+UseParallelGC", "-XX:ActiveProcessorCount=2", "-cp","app:app/lib/*","com.microsoft.azure.simpletodo.SimpleTodoApplication"]
39 changes: 39 additions & 0 deletions templates/todo/api/java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Java with Spring Boot REST API

## Setup

### Prerequisites

- Java 17 or later

### Local Environment

#### Environment variables

The following environment variables are available for configuration:

- `AZURE_KEY_VAULT_ENDPOINT`. If set, other secret environment properties such as `AZURE_COSMOS_CONNECTION_STRING` are loaded from KeyVault.
- `AZURE_COSMOS_CONNECTION_STRING`. A direct override for specifying the Cosmos DB connection string (Mongo DB also supported).
- `APPLICATIONINSIGHTS_CONNECTION_STRING`. (Optional) Connection string of an Application Insights instance for telemetry to be logged.

### Build & Compile

Run `./mvnw package` to build & compile the application in the `target` directory.
`./mvnw package -DskipTests` may be used instead to skip start-up tests that will require app configuration defined.

### Run the application locally

Run `./mvnw spring-boot:run` to start the local development server.

The REST API will be available at `http://localhost:3100`.

### Build and run the Docker image

```bash
docker build . -t java-todo@latest
docker run -e AZURE_COSMOS_CONNECTION_STRING=$AZURE_COSMOS_CONNECTION_STRING -p 3100:3100 -t java-todo@latest
```

### Regenerate API from OpenAPI spec

Run `./mvnw -P openapigen compile` to regenerate the API model and interfaces from the OpenAPI spec.
Loading