Giter VIP home page Giter VIP logo

mitulashah / container-apps-store-api-microservice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure-samples/container-apps-store-api-microservice

0.0 0.0 0.0 1.85 MB

Sample microservices solution using Azure Container Apps, Dapr, Cosmos DB, and Azure API Management

License: MIT License

Shell 39.27% JavaScript 11.72% Python 5.31% Go 2.00% CSS 5.03% Dockerfile 6.75% Pug 2.81% Bicep 27.11%

container-apps-store-api-microservice's Introduction

Container Apps Store Microservice Sample

This repository was created to help users deploy a microservice-based sample application to Azure Container Apps.

Azure Container Apps is a managed serverless container offering for building and deploying modern apps at scale. It enables developers to deploy containerized apps without managing container orchestration. This sample makes use of the Distributed Application Runtime (Dapr), which is integrated deeply into the container apps platform.

Dapr is a CNCF project that helps developers overcome the inherent challenges presented by distributed applications, such as state management and service invocation. Container Apps also provides a fully-managed integration with the Kubernetes Event Driven Autoscaler (KEDA). KEDA allows your containers to autoscale based on incoming events from external services such Azure Service Bus or Redis.

Solution Overview

image of architecture

There are three main microservices in the solution.

Store API (node-app)

The node-app is an express.js API that exposes three endpoints. / will return the primary index page, /order will return details on an order (retrieved from the order service), and /inventory will return details on an inventory item (retrieved from the inventory service).

Order Service (python-app)

The python-app is a Python flask app that will retrieve and store the state of orders. It uses Dapr state management to store the state of the orders. When deployed in Container Apps, Dapr is configured to point to an Azure Cosmos DB to back the state.

Inventory Service (go-app)

The go-app is a Go mux app that will retrieve and store the state of inventory. For this sample, the mux app just returns back a static value.

Deploy via GitHub Actions

IMPORTANT NOTE: This tutorial has been updated (8/2022) to use GITHUB.TOKEN instead of a GH PAT (Personal Access Token). If you have run this tutorial already, and have images that were pushed using a PAT, you will need to delete these from GHCR for the workflow to successfully write the updated images.

The entire solution is configured with GitHub Actions and Bicep for CI/CD

  1. Fork the sample repo
  2. Create the following required encrypted secrets for the sample
Name Value
AZURE_CREDENTIALS The JSON credentials for an Azure subscription. Make sure the Service Principal has permissions at the subscription level scope Learn more
RESOURCE_GROUP The name of the resource group to create
  1. Open GitHub Actions, select the Build and Deploy action and choose to run the workflow. If you would like to deploy the sample with API Management, you can update the deployApim parameter to true in the .github/workflows/build-and-deploy.yaml.

    The GitHub action performs the following actions:

    • Build the code and container image for each microservice
    • Push the images to your private GitHub Container Registry using the GITHUB.TOKEN
    • Create an Azure Container Apps environment with an associated Log Analytics workspace and App Insights instance for Dapr distributed tracing
    • Create a Cosmos DB database and associated Dapr component for using Cosmos DB as a state store
    • Create an API Management instance to frontend the node-app API endpoints (optional)
    • Deploy Container Apps for each of the microservices
  2. Once the GitHub Actions have completed successfully, navigate to the Azure Portal and select the resource group you created. Open the node-app container, and browse to the URL. You should see the sample application running. You can go through the UX to create an order through the order microservice, and then navigate to the /orders?id=foo endpoint and /inventory?id=foo to get the status via other microservices.

  3. After calling each microservice, you can open the application insights resource created and select the Application Map, you should see a visualization of your calls between Container Apps (note: it may take a few minutes for the app insights data to ingest and process into the app map view).

Build and Run

Click here for instructions on building and running the application locally

container-apps-store-api-microservice's People

Contributors

greenie-msft avatar jeffhollan avatar lastcoolnameleft avatar matsest avatar paulyuk avatar philliphoff avatar willtsai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.