Todo App Java On Azure
This TodoList app is an Azure Java application. It provides end-to-end CRUD operation to todo list item from front-end AngularJS code. Behind the scene, todo list item data store is Azure CosmosDB DocumentDB. This application uses [Azure CosmosDB] (https://github.com/Azure/azure-cosmosdb-java), [Azure DocumentDB] (https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-introduction) Spring Boot Starter, and AngularJS to interact with Azure. This sample application provides several deployment options to deploy to Azure, pls see deployment section below. With Azure support in Spring Starters, maven plugins and Eclipse/IntelliJ plugins, Azure Java application development and deployment is effortless now.
TOC
- Requirements
- Create Azure Cosmos DB documentDB
- Configuration
- Run it
- Contribution
- Add new features
- Deployment
- Deploy to Azure Web App for Containers using IntelliJ plugin
- Deploy to Azure Web App for Containers using Eclipse plugin
- Deploy to Azure Container Service Kubernetes cluster using Maven plugin
- Deploy to Azure Web App for Containers using Maven plugin
- Deploy to Azure Web App for Container using Jenkins
- Deploy to Azure Web App for Java SE applications using Jenkins
- Deploy to Azure Web App for Tomcat using Jenkins
- Deploy to Azure Container Service using Jenkins
- Deploy to AKS using Jenkins and Blue/Green Deployment
- Build Docker image from git repo in Azure Container Registry then deploy to Azure Kubernetes Service using Jenkins
- Build Docker image from local directory in Azure Container Registry then deploy to Azure Kubernetes Service using Jenkins
- Useful link
Requirements
Create Azure Cosmos DB documentDB
You can follow our steps using Azure CLI 2.0 to deploy an Azure Cosmos DB documentDB, or follow this article to create it from Azure portal.
-
login your Azure CLI, and set your subscription id
az login az account set -s <your-subscription-id>
-
create an Azure Resource Group, and note your group name
az group create -n <your-azure-group-name> -l <your-resource-group-region>
-
create Azure Cosmos DB with DocumentDB kind. Note the
documentEndpoint
field in the response.az cosmosdb create --kind GlobalDocumentDB -g <your-azure-group-name> -n <your-azure-documentDB-name>
Note name of cosmos db must be in lowercase.
-
get your Azure Cosmos DB key, get the
primaryMasterKey
of the DocumentDB you just created.az cosmosdb list-keys -g <your-azure-group-name> -n <your-azure-documentDB-name>
Configuration
-
Note your DocumentDB uri and key from last step, specify a database name but no need to create it. Then modify
src/main/resources/application.properties
file and save it.azure.documentdb.uri=put-your-documentdb-uri-here azure.documentdb.key=put-your-documentdb-key-here azure.documentdb.database=put-your-documentdb-databasename-here
-
If you don't want to modify configuration in the source code manually, you can put variables in this file and set their values in system environment variables:
DOCUMENTDB_URI
,DOCUMENTDB_KEY
andDOCUMENTDB_DBNAME
. Then maven will substitute them during the build phase.azure.documentdb.uri=@env.DOCUMENTDB_URI@ azure.documentdb.key=@env.DOCUMENTDB_KEY@ azure.documentdb.database=@env.DOCUMENTDB_DBNAME@
Run it
- package the project using
mvn package
- Run the project using
java -jar target/todo-app-java-on-azure-1.0-SNAPSHOT.jar
- Open
http://localhost:8080
you can see the web pages to show the todo list app
Clean up
Delete the Azure resources you created by running the following command:
az group delete -y --no-wait -n <your-resource-group-name>
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.