Giter Site home page Giter Site logo

puicchan / app-templates-staticwebapp-cosmosdb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure-samples/app-templates-staticwebapp-cosmosdb

0.0 0.0 0.0 1.25 MB

Static web app sample using VueJs and CosmosDB as data persistence

License: MIT License

JavaScript 0.17% TypeScript 34.00% CSS 1.59% HTML 3.67% Vue 9.17% Bicep 51.39%

app-templates-staticwebapp-cosmosdb's Introduction

Description:

Creating a VueJS Single Page Application on a Static Web App, which queries CosmosDB data through a GraphQL endpoint hosted on an Azure Function

Tech stack:

  • Azure
  • Azure Cosmos DB
  • Azure Functions
  • Azure Front Door
  • Github Actions
  • Bicep
  • GraphQL
  • VueJS

Introduction

This is a quickstart template. It deploys the following:

  • CosmosDB instance with ToDo list sample content
  • Azure Function exposing a GraphQL endpoint to retrieve ToDo lists and list items
  • Single Page Application (VueJS) that shows the content of the to-do lists
  • Azure Front Door instance exposing endpoints to the outside world

Refer to the App Templates repo Readme for more samples that are compatible with AzureAccelerators.

Prerequisites

  • Local shell with Azure CLI installed or Azure Cloud Shell
  • Azure Subscription, on which you are able to create resources and assign permissions
    • View your subscription using az account show
    • If you don't have an account, you can create one for free.

Getting Started

Fork the repository

Fork the repository by clicking the 'Fork' button on the top right of the page. This creates a local copy of the repository for you to work in.

Azure Configuration for GitHub

The newly created GitHub repo uses GitHub Actions to deploy Azure resources and application code automatically. Your subscription is accessed using an Azure Service Principal. This is an identity created for use by applications, hosted services, and automated tools to access Azure resources. The following steps show how to set up GitHub Actions to deploy Azure applications

Create an Azure Service Principal with contributor permissions on the subscription. The subscription-level permission is needed because the deployment includes creation of the resource group itself.

  • Run the following az cli command, either locally on your command line or on the Cloud Shell. Replace {subscription-id} with the id of the subscription in GUID format. {service-principal-name} can be any alfanumeric string, e.g. GithubPrincipal
       az ad sp create-for-rbac --name {service-principal-name} --role contributor --scopes /subscriptions/{subscription-id} --sdk-auth      
  • The command should output a JSON object similar to this:
     {
       "clientId": "<GUID>",
       "clientSecret": "<GUID>",
       "subscriptionId": "<GUID>",
       "tenantId": "<GUID>",
       "activeDirectoryEndpointUrl": "<URL>",
       "resourceManagerEndpointUrl": "<URL>",
       "activeDirectoryGraphResourceId": "<URL>",
       "sqlManagementEndpointUrl": "<URL>",
       "galleryEndpointUrl": "<URL>",
       "managementEndpointUrl": "<URL>"
     }
  • Store the output JSON as the value of a GitHub secret named 'AZURE_CREDENTIALS'
    • Under your repository name, click Settings.
    • In the "Security" section of the sidebar, select Secrets.
    • At the top of the page, click New repository secret
    • Provide the secret name as AZURE_CREDENTIALS
    • Add the output JSON as secret value

GitHub Workflow setup

  1. Change the value of DEPLOYMENT_NAME and DEPLOYMENT_REGION in the build-deploy.yaml workflow file under .github/workflows.
    • The value for DEPLOYMENT_NAME should be globally unique, e.g. yournamedemo1
    • Use only lowercase letters and numbers for DEPLOYMENT_NAME.
    • DEPLOYMENT_REGION should contain an Azure region name, e.g. westeurope, southcentralus, brazilsouth
  2. Run the workflow
    • If workflows are enabled for this repository it should run automatically. To enable the workflow run automatically, Go to Actions and enable the workflow if needed.
    • Workflow can be manually run
      • Under your repository name, click Actions .
      • In the left sidebar, click the workflow "Build and Deploy Application".
      • Above the list of workflow runs, select Run workflow .
      • Use the Branch dropdown to select the workflow's main branch, Click Run workflow .
    • The workflow will create an Azure Resource Group using DEPLOYMENT_NAME as a prefix.

To-Do List website

Once successfully deployed, the application is accessible through the Front Door endpoint hostname ending in azurefd.net. You can find it by looking on the 'actions' tab on Github, where the latest run will show the URL on the summary page. Alternatively, you can look at the "Front Door and CDN Profiles" resource in your Resource Group through the Azure Portal. Optionally, a custom domain can be added to Front Door.

Screenshot of the todolist webpage

app-templates-staticwebapp-cosmosdb's People

Contributors

aarthiem avatar dependabot[bot] avatar gopinathch avatar microsoftopensource avatar nielsams avatar puicchan 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.