This Inventory Hub app is a Java application. It displays product inventory using AngularJS code in client browsers.
Behind the scene, the inventory data store is Azure CosmosDB and Azure Event Hubs as for data ingestion Data ingestion. Event Hubs - is a "fully managed" cloud scale ingestion of events.
This application uses:
- Spring Boot
- Spring Boot Starter with the Azure Cosmos DB SQL API
- Spring Data for Cosmos DB
- Spring Cloud Functions
- Spring Cloud Stream Binder for Kafka
- Spring Security
- Azure Active Directory B2C Spring Boot Starter
- Spring Boot Starter for WebSocket
- AngularJS
- Requirements
- Create Azure Cosmos DB and Event Hub
- Integrate with Spring Security using Azure Active Directory B2C
- Configuration
- Build
- Run Locally
- Deploy to App Service
- Contribution
- Useful links
You can follow steps described in the [deployment folder][../deployment/README.md].
Note down your Cosmos DB uri and key from the last step. Be prepared to specify a database name but there is no need to create it. Pick an Azure Resource Group name and Web app name for App Service - you can use an existing resource group and Web app or let the Maven plugin create one for you. Set these values in system environment variables:
COSMOSDB_URI=put-your-COSMOSDB-uri-here
COSMOSDB_KEY=put-your-COSMOSDB-key-here
COSMOSDB_DBNAME=put-your-COSMOSDB-databasename-here
NOTIFICATIONS_EVENT_HUB_NAME=put-your-eventhub-for-notifications
NOTIFICATIONS_EVENT_HUB_FQDN=put-your-eventhub-fqdn
NOTIFICATIONS_EVENT_HUB_CONSUMER_GROUP_NAME=$(uuidgen)
NOTIFICATIONS_EVENT_HUB_CONNECTION_STRING=put-your-event-hub-connection-string
NOTIFICATION_ERRORS_EVENT_HUB_NAME=put-your-event-hub-name-for-errors
NOTIFICATIONS_STORAGE_CONTAINER_NAME=put-your-storage-container-name
NOTIFICATIONS_STORAGE_CONNECTION_STRING=put-your-storage-connection-string
WEBAPP_RESOURCEGROUP_NAME=put-your-resourcegroup-name-here
WEBAPP_NAME=put-your-webapp-name-here
WEBAPP_REGION=put-your-region-here
APPINSIGHTS_INSTRUMENTATIONKEY=put-your-app-insights-instrumentation-key
DOLLAR=\$
- Create B2C tenant.
- Register your application. For Reply URL enter <your-app-url-copied-from-App-Service-Portal>/home.
- Create a sign-up and sign-in user flow.
- You can also use external identity providers, such as Google, LinkedIn, Microsoft Account, and Facebook.
Note down your AAD B2C configuration settings and set the following values in your environment:
TENANT_NAME=put-your-aad-b2c-tenant-name-here
B2C_CLIENT_ID=put-your-registered-aad-application-b2c-client-id-here
B2C_CLIENT_SECRET=put-your-registered-aad-application-b2c-client-secret
B2C_REPLY_URL=<put-your-application-url>/home
B2C_LOGOUT_SUCCESS_URL=<put-your-application-url>/login
USER_FLOW_SIGNUP_SIGNIN=<put-your-aad-b2c-sign-up-sign-in-user-flow-name-here>
mvn clean package
mvn spring-boot:run
Or if you want to run the application with AAD B2C enabled
mvn spring-boot:run -Dspring.profiles.active=aad
Open http://localhost:8080/
you can see the Inventory Hub app
If you want to enable AAD B2C, append -Dspring.profiles.active=add
to the JAVA_OPTS
App Setting item of azure-webapp-maven-plugin
.
Deploy in one step.
mvn azure-webapp:deploy
...
...
[INFO] Start deploying to Web App inventory-hub...
[INFO] Authenticate with Azure CLI 2.0
[INFO] Stopping Web App before deploying artifacts...
[INFO] Successfully stopped Web App.
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource to /inventory-hub-java-on-azure/dashboard-web-app/target/azure-webapp/inventory-hub
[INFO] Trying to deploy artifact to inventory-hub...
[INFO] Renaming /inventory-hub-java-on-azure/dashboard-web-app/target/azure-webapp/inventory-hub/inventory-hub-1.0-SNAPSHOT.jar to app.jar
[INFO] Deploying the zip package inventory-hub.zip...
[INFO] Successfully deployed the artifact to https://inventory-hub.azurewebsites.net
[INFO] Starting Web App after deploying artifacts...
[INFO] Successfully started Web App.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:13 min
[INFO] Finished at: 2018-04-17T21:34:57-04:00
[INFO] Final Memory: 70M/730M
[INFO] ------------------------------------------------------------------------
Open it in a browser
If you turned on the aad
profile using -Dspring.profiles.active-aad
, it
will look like this:
Delete the Azure resources you created by running the following command:
az group delete -y --no-wait -n <your-resource-group-name>
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.