GithubHelp home page GithubHelp logo

azure-faunadb-serverless's Introduction

Serverless Azure Functions Node.js Template with FaunaDB

This starter template allows quickly creating a Node.js-based service to Azure Functions. It relies on the serverless-azure-functions plugin, and uses the faunadb client library, and therefore, before you can deploy it, you simply need to run npm install in order to acquire it (the dependencies are already saved in the package.json file).

Setting up your Azure credentials

Once the serverless-azure-functions plugin is installed, it expects to find your Azure credentials via a set of well-known environment variables. These will be used to actually authenticate with your Azure account, so that the Serverless CLI can generate the necessary Azure resources on your behalf when you request a deployment (see below).

The following environment variables must be set, with their respective values:

  • azureSubId - ID of the Azure subscription you want to create your service within
  • azureServicePrincipalTenantId - ID of the tenant that your service principal was created within
  • azureServicePrincipalClientId - ID of the service principal you want to use to authenticate with Azure
  • azureServicePrincipalPassword - Password of the service principal you want to use to authenticate with Azure

For details on how to create a service principal and/or acquire your Azure account's subscription/tenant ID, refer to the Azure credentials documentation.

Configuring FaunaDB

Before your code can connect with FaunaDB, you need to provision an access key and put the key's secret into the serverless.yml configuration file under the provider.environment.FAUNADB_SECRET key.

To get an access key, sign up for free for FaunaDB, navigate to the key creation form on the FaunaDB cloud dashboard and create a key for the database you want to connect to. In most cases, you should select the "server" role.

The example query in handler.js does not depend on any schema or data. Learn more about FaunaDB's query language or see our CRUD example for Lambda.

Deploying the service

Once your Azure credentials are set, you can immediately deploy your service via the following command:

serverless deploy

This will create the necessary Azure resources to support the service and events that are defined in your serverless.yml file.

Invoking and inspecting a function

With the service deployed, you can test it's functions using the following command:

serverless invoke -f hello

Additionally, if you'd like to view the logs that a function generates (either via the runtime, or create by your handler by calling context.log), you can simply run the following command:

serverless logs -f hello

Cleaning up

Once you're finished with your service, you can remove all of the generated Azure resources by simply running the following command:

serverless remove

Issues / Feedback / Feature Requests?

If you have any issues, comments or want to see new features, please file an issue in the project repository:

https://github.com/serverless/serverless-azure-functions

azure-faunadb-serverless's People

Contributors

jchris 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.