Java on Azure examples

Overview

Java on Azure Examples

This GitHub repository contains a set of Azure examples specifically for Java developers to quickly get started with Azure. Please use the issue tracker to leave feedback, file issues or to propose other examples.

Getting started

To work with these examples it is assumed you have the Azure CLI installed, and you have logged in and set your default subscription. If you haven't done so follow the steps below.

Note logging in and setting your default subscription needs to be done once per terminal session.

Install Azure CLI

To setup the Azure CLI, please visit Install the Azure CLI. And once you are done come back to this README.

Login into Azure

  az login

Set your default subscription

Get a list of your subscriptions

  az account list --output table

Set your default subscription for this session using the subscription id from the previous output

  az account set --subscription "subscription-id"

Azure App Service examples

Name Link Status
1. Deploy a web application on a managed Tomcat Workflow appservice/tomcat-helloworld/README.md
2. Create an App Service Plan Workflow appservice/create-plan/README.md
3. Delete an App Service Plan Workflow appservice/delete-plan/README.md
4. Scale your App Service Plan manually Workflow appservice/scale-manually/README.md
5. Delete your web application Workflow appservice/delete-webapp/README.md
6. List your web applications Workflow appservice/list-webapp/README.md
7. Create a deployment slot Workflow appservice/create-deployment-slot/README.md
8. Deploy to a deployment slot Workflow appservice/deploy-to-deployment-slot/README.md
9. Deploy Tomcat using a Docker image Workflow appservice/docker-tomcat/README.md
10. Deploy Jetty using a Docker image Workflow appservice/docker-jetty/README.md
11. Deploy Payara using a Docker image Workflow appservice/docker-payara/README.md
12. Deploy Glassfish using a Docker image Workflow appservice/docker-glassfish/README.md
13. Deploy a Spring Boot application using managed JavaSE Workflow appservice/javase-springboot/README.md
14. Deploy WildFly using a Docker image Workflow appservice/docker-wildfly/README.md
15. Deploy a Quarkus application using managed JavaSE Workflow appservice/javase-quarkus/README.md
16. Deploy a GraalVM application using a Docker image Workflow appservice/docker-graalvm/README.md
17. Swap a deployment slot Workflow appservice/swap-deployment-slot/README.md
18. Deploy a web application on a managed JBoss EAP Workflow appservice/jboss-eap-helloworld/README.md

Azure Container Instances examples

Name Link Status
1. Deploy a Quarkus application Workflow aci/quarkus/README.md
2. Deploy Tomcat Workflow aci/tomcat/README.md
3. Deploy WildFly Workflow aci/wildfly/README.md

Azure Container Registry examples

Name Link Status
1. Create an Azure Container registry Workflow acr/create/README.md
2. Create Maven settings.xml Workflow acr/create-settings-xml/README.md
3. Create an 'acrpull' Service Principal Workflow acr/create-acrpull-service-principal/README.md
4. Push a Glassfish Docker image Workflow acr/glassfish/README.md
5. Push a GraalVM Docker image Workflow acr/graalvm/README.md
6. Push a Jetty Docker image Workflow acr/jetty/README.md
7. Push a Payara Docker image Workflow acr/payara/README.md
8. Push a Quarkus Docker image Workflow acr/quarkus/README.md
9. Push a Tomcat Docker image Workflow acr/tomcat/README.md
10. Push a WildFly Docker image Workflow acr/wildfly/README.md

Azure Cosmos DB examples

Name Link Status
1. Create an Azure Cosmos DB Workflow cosmosdb/create/README.md

Azure Database for MySQL examples

Name Link Status
1. Deploy an Azure Database for MySQL Workflow mysql/create/README.md
2. Open MySQL server firewall to your IP address Workflow mysql/open-firewall-to-your-ip/README.md
3. Load your MySQL database with data Workflow mysql/load-your-mysql-database-with-data/README.md
4. Get country information (JDBC client) Workflow mysql/get-country/README.md

Azure Database for PostgreSQL examples

Name Link Status
1. Deploy an Azure Database for PostgreSQL Workflow postgresql/create/README.md
2. Open PostgreSQL server firewall to your IP address Workflow postgresql/open-firewall-to-your-ip/README.md
3. Load your PostgreSQL database with data Workflow postgresql/load-your-postgresql-database-with-data/README.md
4. Get country information (JDBC client) Workflow postgresql/get-country/README.md

Azure Functions examples

Name Link Status
1. Install Azure Functions Core Tools Workflow functions/install-tools/README.md
2. Deploy a Java Function Workflow functions/java/README.md
3. Deploy a Cosmos DB output Function Workflow functions/cosmosdb-output/README.md

Azure Key Vault examples

  1. Create an Azure Key Vault
  2. Add a Secret to an Azure Key Vault
  3. Create a self-signed certificate
  4. Create a Spring Boot application with server-side mTLS
  5. Create a Spring Boot application with client-side mTLS
  6. Create a server-side SSL Spring Boot application

Azure Kubernetes Service examples

Name Link Status
1. Create an Azure Kubernetes Service cluster Workflow aks/create/README.md
2. Create a Kube config file using admin access Workflow aks/create-kube-config/README.md
3. Update your cluster to use your Azure Container Registry Workflow aks/use-your-acr/README.md
4. Deploy a Spring Boot application Workflow aks/springboot/README.md
5. Deploy Tomcat Workflow aks/tomcat/README.md
6. Deploy WildFly Workflow aks/wildfly/README.md

Azure Red Hat OpenShift examples

  1. Deploy an Azure Red Hat OpenShift cluster

Azure Resource Group examples

Name Link Status
1. Create an Azure Resource Group Workflow group/create/README.md
2. Delete an Azure Resource Group Workflow group/delete/README.md

Azure Service Bus examples

  1. Create an Azure Service Bus
  2. Create an Azure Service Bus Queue
  3. Send a message
  4. Receive a message
  5. Send a JMS message
  6. Receive a JMS message

Azure Spring Cloud examples

Name Link Status
1. Create an Azure Spring Cloud Workflow spring-cloud/create/README.md
2. Deploy a Spring Boot application to Azure Spring Cloud Workflow spring-cloud/helloworld/README.md
3. Configure the Azure Spring Cloud Config Server Workflow spring-cloud/config-server/README.md

Azure SQL Database examples

Name Link Status
1. Deploy an Azure SQL Database Workflow mssql/create/README.md
2. Open Azure SQL server firewall to your IP address Workflow mssql/open-firewall-to-your-ip/README.md
3. Load your Azure SQL database with data Workflow mssql/load-your-mssql-database-with-data/README.md
4. Get country information (JDBC client) Workflow mssql/get-country/README.md

Azure Storage examples

  1. Create an Azure Storage Account
  2. Enabled static website hosting on Azure Storage
  3. Upload files to static website
Comments
  • What about grouping the sample per service category ?

    What about grouping the sample per service category ?

    Please provide us with the following information:

    This issue is for a: (mark with an x)

    - [ ] bug report -> please search issues before submitting
    - [x] feature request
    - [ ] documentation issue or request
    - [ ] regression (a behavior that used to work and stopped in a new release)
    

    Mention any other details that might be useful

    The samples are all ordered by service (e.g. AKS, CosmosDB...) and not by service category (e.g. Compute, Databases...) which then end up following an alphabetical order:

    aci/
    acr/
    adx/
    aks/
    appservice/
    aro/
    cosmosdb/
    eventhubs/
    functions/
    group/
    keyvault/
    mssql/
    mysql/
    postgresql/
    redis/
    servicebus/
    spring-cloud/
    storage/
    

    If you look at something like Azure Charts, the services are ordered per category:

    AI + Machine Learning
    Analytics
    Compute
    Databases
    Development
    Identity + Security
    IoT + MR
    Integration
    Management + Governance
    Media + Comms
    Migration
    Networking
    Storage
    

    What about reordering the samples and grouping them by category ? We could end up, either with an extra directory:

    analytics/
      adx/
      eventhubs/
    compute/
      aci/
      acr/
      aks/
      appservice/
      aro/
      functions/
    core/
      group/
    databases/
      cosmosdb/
      mssql/
      mysql/
      postgresql/
      redis/
    development/
      spring-cloud/
    integration/
      servicebus/
    security/
      keyvault/
    storage/
      storage/
    

    Or with a prefix of the category:

    analytics-adx/
    analytics-eventhubs/
    compute-aci/
    compute-acr/
    compute-aks/
    compute-appservice/
    compute-aro/
    compute-functions/
    core-group/
    databases-cosmosdb/
    databases-mssql/
    databases-mysql/
    databases-postgresql/
    databases-redis/
    development-spring-cloud/
    integration-servicebus/
    security-keyvault/
    storage-storage/
    

    We can even flatten the entire structure:

    analytics-adx-create-database/
    analytics-adx-create-table/
    analytics-adx-create/
    analytics-adx-ingest-client/
    analytics-eventhubs-create-eventhub/
    analytics-eventhubs-create-namespace/
    analytics-eventhubs-receive-event/
    analytics-eventhubs-send-event
    ...
    
    opened by agoncal 3
  • Document how to run the GitHub Actions on a fork when contributing

    Document how to run the GitHub Actions on a fork when contributing

    Please provide us with the following information:

    This issue is for a: (mark with an x)

    - [ ] bug report -> please search issues before submitting
    - [ ] feature request
    - [x] documentation issue or request
    - [ ] regression (a behavior that used to work and stopped in a new release)
    

    Mention any other details that might be useful

    When we fork the repository, workflows are not working because the Azure CLI cannot log in:

     Az CLI Login failed. Please check the credentials. For more information refer https://aka.ms/create-secrets-for-GitHub-workflows
    

    When looking at the workflows, it looks like we need to set the AZURE_CREDENTIALS secret. But still, it does not work.

    Is there any other secret that we need to add ? It would be nice to document this in the CONTRIBUTING.md file so people know how to execute the workflows on their fork .

    documentation stale 
    opened by agoncal 3
  • Create workflow for compiling the samples

    Create workflow for compiling the samples

    When compiling the samples from the root (mvn install) I realized that one does not compile. We should create a workflow that compiles all the samples when we push

    This issue is for a: (mark with an x)

    - [x] bug report -> please search issues before submitting
    - [ ] feature request
    - [ ] documentation issue or request
    - [ ] regression (a behavior that used to work and stopped in a new release)
    

    Minimal steps to reproduce

    $ git clone https://github.com/Azure-Samples/java-on-azure-examples.git
    $ mvn install
    

    Any log messages given by the failure

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  12.276 s
    [INFO] Finished at: 2022-05-09T13:32:41+02:00
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.0:compile (default-compile) on project appservice-javase-springboot: Compilation failure: Compilation failure:
    [ERROR] error reading /Users/agoncal/.m2/repository/org/springframework/spring-core/5.3.18/spring-core-5.3.18.jar; zip file is empty
    [ERROR] /Users/agoncal/Documents/Code/Temp/java-on-azure-examples/compute/appservice/javase-springboot/src/main/java/examples/azure/appservice/javase/springboot/HelloWorldApplication.java:[1,1] cannot access examples.azure.appservice.javase.springboot
    [ERROR]   zip END header not found
    [ERROR] /Users/agoncal/Documents/Code/Temp/java-on-azure-examples/compute/appservice/javase-springboot/src/main/java/examples/azure/appservice/javase/springboot/HelloWorldController.java:[7,8] cannot access java.lang
    [ERROR]   zip END header not found
    [ERROR] /Users/agoncal/Documents/Code/Temp/java-on-azure-examples/compute/appservice/javase-springboot/src/main/java/examples/azure/appservice/javase/springboot/HelloWorldController.java:[6,2] cannot find symbol
    [ERROR]   symbol: class RestController
    [ERROR] /Users/agoncal/Documents/Code/Temp/java-on-azure-examples/compute/appservice/javase-springboot/src/main/java/examples/azure/appservice/javase/springboot/HelloWorldController.java:[10,12] cannot find symbol
    [ERROR]   symbol:   class String
    [ERROR]   location: class examples.azure.appservice.javase.springboot.HelloWorldController
    
    ci 
    opened by agoncal 1
  • Add

    Add "Azure Container Apps" example

    This issue is for a: (mark with an x)

    - [ ] bug report -> please search issues before submitting
    - [X] feature request
    - [ ] documentation issue or request
    - [ ] regression (a behavior that used to work and stopped in a new release)
    

    See:

    • #121
    • #122
    • #123

    Mention any other details that might be useful

    Azure Container Apps is still in preview but we could add a few sample on how to create a container app, a log environment, deploy an image, etc.

    containerapp 
    opened by agoncal 1
  • Add

    Add "Create a Jump Box" example

    This issue is for a: (mark with an x)

    - [ ] bug report -> please search issues before submitting
    - [x] feature request
    - [ ] documentation issue or request
    - [ ] regression (a behavior that used to work and stopped in a new release)
    

    Mention any other details that might be useful

    It would be nice to have an example on how to create a Jump Box (like shown in this article https://4sysops.com/archives/deploying-an-azure-jumpbox-jump-server/)

    stale network 
    opened by agoncal 1
  • What about having a global SLEEP variable in the workflows ?

    What about having a global SLEEP variable in the workflows ?

    This issue is for a: (mark with an x)

    - [ ] bug report -> please search issues before submitting
    - [x] feature request
    - [ ] documentation issue or request
    - [ ] regression (a behavior that used to work and stopped in a new release)
    

    Mention any other details that might be useful

    Some workflows fail, once in a while, in timeout. That's because, sometimes, the sleep time is not enough. For example, the following script deploys an image, waits for 3mn, and checks the app is deployed. If it's not the case, it will fail.

    What about introducing a SLEEP variable that would be global for all the workflows? This way, if we see that 180s is not enough sometimes, we could easily increase it globally.

              mvn azure-webapp:deploy \
              --settings=$SETTINGS_XML \
              -DappName=$APPSERVICE_DOCKER_GLASSFISH \
              -DimageName=glassfish:latest \
              -DappServicePlan=$APPSERVICE_PLAN \
              -DresourceGroup=$RESOURCE_GROUP \
              -DserverId=$ACR_NAME
              
              
              sleep 180
              
              export RESULT=$(az webapp show --resource-group $RESOURCE_GROUP --name $APPSERVICE_DOCKER_GLASSFISH --output tsv --query state)
    
    enhancement stale 
    opened by agoncal 1
  • Cannot ingest data

    Cannot ingest data

    This issue is for a: (mark with an x)

    - [ ] bug report -> please search issues before submitting
    - [ ] feature request
    - [x] documentation issue or request
    - [ ] regression (a behavior that used to work and stopped in a new release)
    

    Minimal steps to reproduce

    If you follow the READMEs to ingest data, it does not work.

    Mention any other details that might be useful

    The first issue is to create a table and enable streaming ingestion (analytics/adx/create-table/README.md). The sample mentions the following command:

    .alter table Events policy streamingingestion enable;
    

    But I have an error : Admin command cannot be executed as streaming ingestion is not enabled

    I checked the documentation and tried the following:

    .alter table Events policy streamingingestion '{"IsEnabled": true}'
    

    But this doesn't work either (same error)

    Then I tried to ingest. The README (analytics/adx/ingest-client/README.md) does not mention that we need to package the code as a JAR (mvn package) and execute it (java -jar target/ingest.jar). But it doesnt work as there are a few env variables missing ADX_ENDPOINT, ADX_CLIENT_ID, ADX_CLIENT_SECRET and ADX_TENANT_ID

    kusto stale 
    opened by agoncal 1
  • Document in CONTRIBUTING how to create a new sample

    Document in CONTRIBUTING how to create a new sample

    This issue is for a: (mark with an x)

    - [ ] bug report -> please search issues before submitting
    - [ ] feature request
    - [x] documentation issue or request
    - [ ] regression (a behavior that used to work and stopped in a new release)
    

    Mention any other details that might be useful

    It would be good to document how to create a new sample (the structure of the readme, the automatic generation of the workflow, to add it to the main readme....)

    documentation stale 
    opened by agoncal 1
  • Fixing by adding a title and changing the branch name to main

    Fixing by adding a title and changing the branch name to main

    Purpose

    • Adding the title of the project
    • Fixing the master branch name to main
    • One line per sentence

    Does this introduce a breaking change?

    [ ] Yes
    [x] No
    

    Pull Request Type

    What kind of change does this Pull Request introduce?

    [ ] Bugfix
    [ ] Feature
    [ ] Code style update (formatting, local variables)
    [ ] Refactoring (no functional changes, no api changes)
    [x] Documentation content changes
    [ ] Other... Please describe:
    
    opened by agoncal 1
  • Adding the refresh parameter to the list of subscriptions

    Adding the refresh parameter to the list of subscriptions

    Purpose

    When displaying the list of Azure subscriptions, you can get old ones that do not exist anymore, that's because the subscriptions are cached locally. Adding the refresh parameter allows the subcriptions list to be refreshed with the ones on the server.

    Does this introduce a breaking change?

    [ ] Yes
    [x] No
    

    Pull Request Type

    What kind of change does this Pull Request introduce?

    [ ] Bugfix
    [ ] Feature
    [ ] Code style update (formatting, local variables)
    [ ] Refactoring (no functional changes, no api changes)
    [x] Documentation content changes
    [ ] Other... Please describe:
    
    opened by agoncal 1
  • Adding editorconfig file and formatting code accordingly

    Adding editorconfig file and formatting code accordingly

    Purpose

    Adding an .editorconfig file and formatting accordingly to the rules. EditorConfig is a nice way to have the same code formatting accross IDEs.

    Does this introduce a breaking change?

    [ ] Yes
    [x] No
    

    Pull Request Type

    What kind of change does this Pull Request introduce?

    [ ] Bugfix
    [ ] Feature
    [x] Code style update (formatting, local variables)
    [ ] Refactoring (no functional changes, no api changes)
    [ ] Documentation content changes
    [ ] Other... Please describe:
    

    Other Information

    • https://editorconfig.org/
    opened by agoncal 1
Owner
Azure Samples
Microsoft Azure code samples and examples in .NET, Java, Python, Node.js, PHP and Ruby
Azure Samples
Implementation of Azure/SAML Single Sign on in PeopleSoft

Azure/SAML SSO in PeopleSoft I had the requirement to implement Microsoft's Azure single sign on (SSO) in PeopleSoft without purchasing Oracle's or Ap

null 9 Aug 24, 2022
This repo for kodlama.io java camp examples

JavaCampExamples This repo for kodlama.io java camp examples Bu repository'de İsteyen herkesin faydalanabilmesi ve örnek alması için Java Kapında yapı

Salih Değirmenci 18 Mar 2, 2022
Java Design Patterns code examples

Java Design Patterns code examples Behavioral In software engineering, behavioral design patterns are design patterns that identify common communicati

Gaboso™ 3 Jun 29, 2022
Examples and HowTos for BouncyCastle and Java Cryptography Extension (JCE)

CryptographicUtilities Examples and HowTos for BouncyCastle and Java Cryptography Extension (JCE) See class "/src/main/java/de/soderer/utilities/crypt

null 1 Dec 19, 2021
Weld, including integrations for Servlet containers and Java SE, examples and documentation

Weld Weld is the reference implementation of CDI: Contexts and Dependency Injection for the Java EE Platform which is the Java standard for dependency

Weld 345 Oct 28, 2022
Java Notes & Codes for better understanding and it contains all the funtions with examples and also added Cheat Sheet for Revision

Java Notes & Codes for better understanding and it contains all the funtions with examples and also added Cheat Sheet for Revision...

Ujjawal Singh 1 Nov 30, 2022
Spring GraphQL examples using Netflix DGS, GraphQL Java and Spring GraphQL

spring-graphql-sample Spring GraphQL examples using the following frameworks and libraries: Netflix DGS(Domain Graph Service) framework Spring GraphQL

Hantsy Bai 56 Dec 20, 2022
The High-Performance Java Persistence book and video course code examples

High-Performance Java Persistence The High-Performance Java Persistence book and video course code examples. I wrote this article about this repositor

Vlad Mihalcea 1.1k Jan 9, 2023
These are examples of work/homework from the Java Camp 2022.

Hi ?? , This is Java Camp 2022 Repository These are examples of work/homework from the Java Camp 2022. ?? I’m currently working on JavaCamp2022 ?? I’m

Sırrı KÖMÜR 3 Oct 19, 2022
This repository contains examples of modern Java features that appear in various videos I'm creating for my courses at Vanderbilt.

This repository contains examples of modern Java features that appear in various videos I'm creating for my courses at Vanderbilt. It's organized into

Douglas C. Schmidt 7 Dec 1, 2022
:wrench: LibGDX/LWJGL tutorials and examples

lwjgl-basics is a minimal shader-based library for 2D LWJGL sprite games. It provides essential utilities for handling textures, shaders, and sprite r

Matt DesLauriers 1.8k Jan 3, 2023
Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API

Swagger Core NOTE: If you're looking for Swagger Core 1.5.X and OpenAPI 2.0, please refer to 1.5 branch. NOTE: Since version 2.1.7 Swagger Core suppor

Swagger 7.1k Jan 5, 2023
about learning Spring Boot via examples. Spring Boot 教程、技术栈示例代码,快速简单上手教程。

Spring Boot 学习示例 Spring Boot 使用的各种示例,以最简单、最实用为标准,此开源项目中的每个示例都以最小依赖,最简单为标准,帮助初学者快速掌握 Spring Boot 各组件的使用。 Spring Boot 中文索引 | Spring Cloud学习示例代码 | Spring

纯洁的微笑 28.3k Jan 1, 2023
You are looking for examples, code snippets, sample applications for Spring Integration? This is the place.

Spring Integration Samples Note This (master) branch requires Spring Integration 5.0 or above. For samples running against earlier versions of Spring

Spring 2.1k Dec 30, 2022
The quickstarts demonstrate JBoss EAP, Jakarta EE 8 and a few additional technologies. They provide small, specific, working examples that can be used as a reference for your own project.

shared-doc/attributes.adoc WildFly Quickstarts The quickstarts demonstrate Jakarta EE 8 and a few additional technologies from the WildFly stack. They

JBoss Developer 792 Dec 16, 2022
A collection of bite size examples for using chrome DevTools protocol commands with Selenium Webdriver v4.

selenium-devtools-guide A collection of bite size examples for using chrome DevTools protocol commands with Selenium Webdriver v4. Chrome Devtools Pro

Sudharsan Selvaraj 4 Aug 12, 2021
FIDO2(WebAuthn) server officially certified by FIDO Alliance and Relying Party examples.

Overview FIDO (Fast IDentity Online) is an open standard for online authentication. It is designed to solve the password problems stemming from a lot

LINE 400 Jan 5, 2023
Examples using libp5x

Examples for libp5x libp5x is a modularized fork of Processing used inside PraxisLIVE. Based on Processing v3.5.3, it fully supports Java 11+ and the

Codelerity 4 May 17, 2021
This repository contains examples using TestContainers in a Spring Boot Application

Sample REST CRUD API with Spring Boot, Mysql, JPA and Hibernate Using TestContainer to assure our Integration/API testing Steps to Setup 1. Build and

Guilherme Rogatto 4 Nov 29, 2021
An examples of creating test records in the database with Spring Boot + Spring Data + JPA usage.

Spring Boot + JPA — Clear Tests An examples of creating test records in the database with Spring Boot + Spring Data + JPA usage. Check out the article

Semyon Kirekov 8 Nov 24, 2022