21 | Response: 22 |
23 | 24 | 25 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /quarkus-micronaut/06-build-a-quarkus-ai-application-using-azure-openai/ai-weather-application/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.log.level=INFO 2 | quarkus.http.read-timeout=120s 3 | quarkus.langchain4j.azure-openai.timeout=1m 4 | quarkus.langchain4j.azure-openai.log-requests=true 5 | quarkus.langchain4j.azure-openai.log-responses=true 6 | quarkus.native.resources.includes=Paris.csv 7 | -------------------------------------------------------------------------------- /quarkus-micronaut/06-build-a-quarkus-ai-application-using-azure-openai/ai-weather-application/src/test/java/com/example/AiWeatherResourceIT.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import io.quarkus.test.junit.QuarkusIntegrationTest; 4 | 5 | @QuarkusIntegrationTest 6 | class AiWeatherResourceIT extends AiWeatherResourceTest { 7 | // Execute the same tests but in packaged mode. 8 | } 9 | -------------------------------------------------------------------------------- /quarkus-micronaut/06-build-a-quarkus-ai-application-using-azure-openai/ai-weather-application/src/test/java/com/example/AiWeatherResourceTest.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import io.quarkus.test.junit.QuarkusTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | @QuarkusTest 7 | class AiWeatherResourceTest { 8 | @Test 9 | void testQuarkusContextLoads() { 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /quarkus-micronaut/06-build-a-quarkus-ai-application-using-azure-openai/media/01-question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/java-on-aca-with-ai/16f838fb924b7481fd190b51eda9c51c65ca0d2c/quarkus-micronaut/06-build-a-quarkus-ai-application-using-azure-openai/media/01-question.png -------------------------------------------------------------------------------- /quarkus-micronaut/06-build-a-quarkus-ai-application-using-azure-openai/media/02-question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/java-on-aca-with-ai/16f838fb924b7481fd190b51eda9c51c65ca0d2c/quarkus-micronaut/06-build-a-quarkus-ai-application-using-azure-openai/media/02-question.png -------------------------------------------------------------------------------- /quarkus-micronaut/06-build-a-quarkus-ai-application-using-azure-openai/media/03-question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/java-on-aca-with-ai/16f838fb924b7481fd190b51eda9c51c65ca0d2c/quarkus-micronaut/06-build-a-quarkus-ai-application-using-azure-openai/media/03-question.png -------------------------------------------------------------------------------- /quarkus-micronaut/06-build-a-quarkus-ai-application-using-azure-openai/media/04-question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/java-on-aca-with-ai/16f838fb924b7481fd190b51eda9c51c65ca0d2c/quarkus-micronaut/06-build-a-quarkus-ai-application-using-azure-openai/media/04-question.png -------------------------------------------------------------------------------- /quarkus-micronaut/README.md: -------------------------------------------------------------------------------- 1 | # Build, Run and Monitor Intelligent Quarkus and Micronaut Java Apps on Azure Container Apps and Azure OpenAI 2 | 3 | This series of guides focus on building Java applications using Quarkus and Micronaut frameworks and running them on Azure Container Apps. It also covers how to use Azure OpenAI to build AI applications. 4 | 5 | ## [00 - Prerequisites and Setup](00-setup-your-environment/README.md) 6 | 7 | Prerequisites and environment setup. 8 | 9 | ## [01 - Build a simple Java application](01-build-a-simple-java-application/README.md) 10 | 11 | Build the simplest possible Java application using the [Quarkus maven plugin](https://quarkus.io/guides/quarkus-maven-plugin) and [Micronaut Launch](https://launch.micronaut.io/). 12 | 13 | ## [02 - Build a reactive and native Quarkus microservice using PostgreSQL](02-build-a-reactive-and-native-quarkus-microservice-using-postgresql/README.md) 14 | 15 | Build a reactive and native [Quarkus](https://quarkus.io/) microservice that uses [Quarkus Reactive](https://quarkus.io/guides/quarkus-reactive-architecture) and [Quarkus Native](https://quarkus.io/guides/building-native-image). The service is bound to an [Azure Database for PostgreSQL Flexible Server](https://learn.microsoft.com/azure/postgresql/flexible-server/overview), and it uses [Liquibase](https://quarkus.io/guides/liquibase) to manage database schema migrations including initial data population. 16 | 17 | ## [03 - Build a Micronaut microservice using MySQL](03-build-a-micronaut-microservice-using-mysql/README.md) 18 | 19 | Build a [Micronaut](https://micronaut.io/) microserver that uses [Micronaut Data JDBC](https://guides.micronaut.io/latest/micronaut-data-jdbc-repository-maven-java.html). The service is bound to an [Azure Database For MySQL Flexible server](https://learn.microsoft.com/azure/mysql/flexible-server/overview), and it uses [Flyway](https://guides.micronaut.io/latest/micronaut-flyway-maven-java.html) to manage database schema migrations including initial data population. 20 | 21 | ## [04 - Build a NGINX Reverse Proxy](04-build-a-nginx-reverse-proxy/README.md) 22 | 23 | Build a [NGINX Reverse Proxy](https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/) to route HTTP requests to internal services. 24 | 25 | ## [05 - Putting it all together, a complete microservice stack](05-putting-it-all-together-a-complete-microservice-stack/README.md) 26 | 27 | Use a front-end to access graphically our complete microservice stack. 28 | 29 | ## [06 - Build a Quarkus AI application using Azure OpenAI](06-build-a-quarkus-ai-application-using-azure-openai/README.md) 30 | 31 | Build an AI application that uses [Azure OpenAI Service](https://learn.microsoft.com/en-us/azure/ai-services/openai/) in order to analyze and forecast weather based on historical data. 32 | -------------------------------------------------------------------------------- /spring/00-setup-your-environment/README.md: -------------------------------------------------------------------------------- 1 | # 00 - Setup your environment 2 | 3 | __This guide is part of the [Build, Run and Monitor Intelligent Spring Java Apps on Azure Container Apps and Azure OpenAI](../README.md)__ 4 | 5 | In this section, we'll set up everything you need to expeditiously complete the lab. 6 | 7 | --- 8 | 9 | ## Creating Azure Resources 10 | 11 | To save time, we provide an ARM template for creating all the Azure resources you will need for this lab other than the Azure Container Apps itself. Use the "Deploy to Azure" button below. 12 | 13 | > 💡 Use the following settings for deploying the Azure Template: 14 | > 15 | > * Create a new resource group. 16 | > * In the location field, select the nearest region from [the list of regions where Azure Container Apps is available](https://azure.microsoft.com/global-infrastructure/services/?products=container-apps®ions=all). 17 | > * Save the MySQL password you specify in this step. You will need it in section 6. If you don't set one, it will be `super$ecr3t`. 18 | 19 | [](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fmicrosoft%2Fjava-on-aca-with-ai%2Fmain%2Fspring%2F00-setup-your-environment%2Fazuredeploy.json) 20 | 21 | > ⏱ The resource provisioning will take some time. __Do not wait!__ Continue with the workshop. 22 | 23 | > 💡 If the "Deploy to Azure" button above doesn't work, you can try to directly open [https://portal.azure.com/#create/Microsoft.Template/uri/https://raw.githubusercontent.com/microsoft/java-on-aca-with-ai/main/spring/00-setup-your-environment/azuredeploy.json](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fmicrosoft%2Fjava-on-aca-with-ai%2Fmain%2Fspring%2F00-setup-your-environment%2Fazuredeploy.json) in your browser, or follow [Create and deploy ARM templates by using the Azure portal](https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/quickstart-create-templates-use-the-portal?source=recommendations) to deploy the [azuredeploy.json](azuredeploy.json) file. 24 | 25 | ## Prerequisites 26 | 27 | This training lab requires the following to be installed on your machine: 28 | 29 | * [JDK 17](https://docs.microsoft.com/java/openjdk/download#openjdk-17) 30 | * A text editor or an IDE. If you do not already have an IDE for Java development, we recommend using [Visual Studio Code](https://code.visualstudio.com) with the [Java Extension Pack](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack). 31 | 32 | * The Bash shell. While Azure CLI should behave identically on all environments, shell semantics vary. Therefore, only bash can be used with the commands in this training. To complete this training on Windows, use [Windows Subsystem for Linux](https://learn.microsoft.com/windows/wsl/install). 33 | 34 | * [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) version 2.61.0 or later. You can check the version of your current Azure CLI installation by running: 35 | 36 | ```bash 37 | az --version 38 | ``` 39 | 40 | > 💡 If you try the command above and you see the error `bash: az: command not found`, run the following command: `alias az='az.cmd'` and try again. 41 | 42 | * 🚧 The `containerapp` extension for Azure CLI. You can install or update this extension after installing Azure CLI by running `az extension add --name containerapp --upgrade --allow-preview true`. 43 | 44 | > 💡 In some sections, you will access the UI of the Microservice applications in a web browser. Use the [Microsoft Edge](https://microsoft.com/edge), Google Chrome, or Firefox for these sections. 45 | 46 | The environment variable `JAVA_HOME` should be set to the path of the JDK installation. The directory specified by this path should have `bin`, `jre`, and `lib` among its subdirectories. Further, ensure your `PATH` variable contains the directory `${JAVA_HOME}/bin`. To test, type `which javac` into bash shell ensure the resulting path points to a file inside `${JAVA_HOME}/bin`. 47 | 48 | You can then use Visual Studio Code or an IDE of your choice. 49 | 50 | --- 51 | 52 | ➡️ Next guide: [01 - Build a simple Java application](../01-build-a-simple-java-application/README.md) 53 | -------------------------------------------------------------------------------- /spring/00-setup-your-environment/azuredeploy.parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "location": { 6 | "value": "canadacentral" 7 | }, 8 | "mysql_admin_password": { 9 | "value": "super$ecr3t" 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /spring/01-build-a-simple-java-application/media/01-application-url.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/java-on-aca-with-ai/16f838fb924b7481fd190b51eda9c51c65ca0d2c/spring/01-build-a-simple-java-application/media/01-application-url.png -------------------------------------------------------------------------------- /spring/01-build-a-simple-java-application/simple-application/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring/01-build-a-simple-java-application/simple-application/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/java-on-aca-with-ai/16f838fb924b7481fd190b51eda9c51c65ca0d2c/spring/01-build-a-simple-java-application/simple-application/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring/01-build-a-simple-java-application/simple-application/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 3 | -------------------------------------------------------------------------------- /spring/01-build-a-simple-java-application/simple-application/pom.xml: -------------------------------------------------------------------------------- 1 | 2 |21 | Response: 22 |
23 | 24 | 25 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /spring/09-build-a-spring-ai-application-using-azure-openai/ai-weather-application/src/main/resources/static/prompt.template: -------------------------------------------------------------------------------- 1 | Today is {today}. 2 | You will act as a meteorological expert who helps analyze and forecast weather. 3 | Given the following historical weather (in CSV format with header) of {city} over an entire year, please answer the questions and make predictions. 4 | Don't use any external data. 5 | 6 | {weatherHistory} -------------------------------------------------------------------------------- /spring/09-build-a-spring-ai-application-using-azure-openai/ai-weather-application/src/test/java/com/example/demo/AiWeatherApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class AiWeatherApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring/09-build-a-spring-ai-application-using-azure-openai/media/01-question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/java-on-aca-with-ai/16f838fb924b7481fd190b51eda9c51c65ca0d2c/spring/09-build-a-spring-ai-application-using-azure-openai/media/01-question.png -------------------------------------------------------------------------------- /spring/09-build-a-spring-ai-application-using-azure-openai/media/02-question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/java-on-aca-with-ai/16f838fb924b7481fd190b51eda9c51c65ca0d2c/spring/09-build-a-spring-ai-application-using-azure-openai/media/02-question.png -------------------------------------------------------------------------------- /spring/09-build-a-spring-ai-application-using-azure-openai/media/03-question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/java-on-aca-with-ai/16f838fb924b7481fd190b51eda9c51c65ca0d2c/spring/09-build-a-spring-ai-application-using-azure-openai/media/03-question.png -------------------------------------------------------------------------------- /spring/09-build-a-spring-ai-application-using-azure-openai/media/04-question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/java-on-aca-with-ai/16f838fb924b7481fd190b51eda9c51c65ca0d2c/spring/09-build-a-spring-ai-application-using-azure-openai/media/04-question.png -------------------------------------------------------------------------------- /spring/README.md: -------------------------------------------------------------------------------- 1 | # Build, Run and Monitor Intelligent Spring Java Apps on Azure Container Apps and Azure OpenAI 2 | 3 | This series of guides focus on building Java applications using Spring framwork and running them on Azure Container Apps. It also covers how to use Azure OpenAI to build AI applications. 4 | 5 | ## [00 - Prerequisites and Setup](00-setup-your-environment/README.md) 6 | 7 | Prerequisites and environment setup. 8 | 9 | ## [01 - Build a simple Java application](01-build-a-simple-java-application/README.md) 10 | 11 | Build the simplest possible Java application using the Spring Initializr. 12 | 13 | ## [02 - Create Managed Eureka Server for Spring](02-create-managed-eureka-server-for-spring/README.md) 14 | 15 | Create a [Spring Cloud Eureka Server](https://spring.io/projects/spring-cloud-netflix), that will be entirely managed and supported by Azure Container Apps, to be used by Spring Boot microservices. 16 | 17 | ## [03 - Create and configure Managed Config Server for Spring](03-create-and-configure-managed-config-server-for-spring/README.md) 18 | 19 | Create a managed [Spring Cloud Config Server](https://cloud.spring.io/spring-cloud-config) and configure it to access Git repository. 20 | 21 | ## [04 - Build a Spring Boot microservice using Spring Cloud features](04-build-a-spring-boot-microservice-using-spring-cloud-features/README.md) 22 | 23 | Build a Spring Boot microservice that is cloud-enabled: it uses a [Spring Cloud Eureka Server](https://spring.io/projects/spring-cloud-netflix) and a [Spring Cloud Config Server](https://cloud.spring.io/spring-cloud-config) which are both managed and supported by Azure Container Apps. 24 | 25 | ## [05 - Build a reactive Spring Boot microservice using Cosmos DB](05-build-a-reactive-spring-boot-microservice-using-cosmosdb/README.md) 26 | 27 | Build a reactive Spring Boot microservice, that uses the [Spring reactive stack](https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html) and is bound to a [Cosmos DB database](https://docs.microsoft.com/en-us/azure/cosmos-db/) in order to access a globally-distributed database with optimum performance. 28 | 29 | ## [06 - Build a Spring Boot microservice using MySQL](06-build-a-spring-boot-microservice-using-mysql/README.md) 30 | 31 | Build a classical Spring Boot application that uses JPA to access a [MySQL database managed by Azure](https://docs.microsoft.com/en-us/azure/mysql/). 32 | 33 | ## [07 - Build a Spring Cloud Gateway](07-build-a-spring-cloud-gateway/README.md) 34 | 35 | Build a [Spring Cloud Gateway](https://spring.io/projects/spring-cloud-gateway) to route HTTP requests to the correct Spring Boot microservices. 36 | 37 | ## [08 - Putting it all together, a complete microservice stack](08-putting-it-all-together-a-complete-microservice-stack/README.md) 38 | 39 | Use a front-end to access graphically our complete microservice stack. 40 | 41 | ## [09 - Build a Spring AI application using Azure OpenAI](09-build-a-spring-ai-application-using-azure-openai/README.md) 42 | 43 | Build an AI application that uses [Azure OpenAI Service](https://learn.microsoft.com/en-us/azure/ai-services/openai/) in order to analyze and forecast weather based on historical data. 44 | --------------------------------------------------------------------------------