Git Product home page Git Product logo

isabella232 / msdocs-javascript-nodejs-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure-samples/msdocs-javascript-nodejs-server

0.0 0.0 0.0 220 KB

JavaScript Express.js app serving static vanilla JS. This sample app is used in Microsoft Docs to demonstrate how to integrate Azure Storage, Azure Cosmos DB, and Azure Active Directory.

License: MIT License

JavaScript 59.72% CSS 0.52% HTML 39.75%

msdocs-javascript-nodejs-server's Introduction

JavaScript on Azure Learn Path - Module 2 - Deploying a basic app to Azure

This Learn module requires the following Azure resources to deploy correctly:

  • Azure App Service
  • Azure Cosmos DB with MongoDB API

Requirements

  • Node.js LTS

Local development

  • Create Azure resources
    • Azure App Service + Cosmos DB for MongoDB API
      • Create resource in Azure portal
      • Create database
      • Create collection
      • Copy the following to the .env file:
        • Connection string
        • Database name
        • Collection name
    • Azure Storage (for images)
      • Create resource
        • Make sure Blob public access is enabled
      • Create container
      • Copy the following to the .env file:
        • Connection string
        • Container name
  • Install npm dependencies: npm install
  • Verify environment variables are set in .env
    • PORT=8080 - default port for Azure App Service
    • MONGODB_URI=
    • MONGODB_URI_DATABASE_NAME=
    • MONGODB_URI_COLLECTION_NAME=
    • AZURE_STORAGE_BLOB_CONNECTIONSTRING=
    • AZURE_STORAGE_BLOB_CONTAINER_NAME=
  • Start the server: npm start
  • Access Web App at: http://127.0.0.1:8080

Azure portal: Configure git to push to Azure App Service

  1. In the Azure portal, for your web app, select Deployment -> Deployment Center.
  2. On the Settings tab, copy the Git Clone URI. This will become your local git value for your remote named Azure.
  3. On the Local Git/FTPS credentials tab, copy the Username and Password under the application scope. These credentials allow you to deploy only to this web app.

Azure CLI: Configure git to push to Azure App Service

  1. Create a user scope credential for the web app.

    az webapp deployment user set --user-name <username> --password <password>
    
  2. After app is created, configure deployment from local git

    az webapp deployment source config-local-git --name <app-name> --resource-group <group-name>
    

    The output contains a URL like: https://@.scm.azurewebsites.net/.git. Use this URL to deploy your app in the next step.

Create local git remote to Azure App Service

  1. In a local terminal window, change the directory to the root of your Git repository, and add a Git remote using the URL you got from your app. If your chosen method doesn't give you a URL, use https://.scm.azurewebsites.net/.git with your app name in .

    git remote add azure <url>
  2. Push to the Azure remote with:

    git push azure <branchname>
  3. In the Git Credential Manager window, enter your user-scope or application-scope credentials, not your Azure sign-in credentials.

    If your Git remote URL already contains the username and password, you won't be prompted.

  4. Review the output. You may see runtime-specific automation.

  5. Browse to your cloud app to verify that the content is deployed:

    http://<app-name>.azurewebsites.net

msdocs-javascript-nodejs-server's People

Contributors

diberry avatar microsoft-github-operations[bot] avatar microsoftopensource 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.