Git Product home page Git Product logo

serverless-azure-functions's Introduction

Azure Functions Plugin

This plugin enables Azure Functions support within the Serverless Framework.

Getting started

1. Get a Serverless Service with Azure as the Provider

  1. Recommend using Node v6.5.0
  2. Install the serverless tooling - npm i -g serverless
  3. Create boilerplate (change my-app to whatever you'd prefer): serverless install --url https://github.com/azure/boilerplate-azurefunctions --name my-app
  4. cd my-app
  5. npm install

2. Set up credentials

We'll set up an Azure Subscription and our service principal. You can learn more in the credentials doc.

  1. Set up an Azure Subscription

    Sign up for a free account @ https://azure.com.

    Azure comes with a free trial that includes $200 of free credit.

  2. . Get the Azure CLI

    npm i -g azure-cli
    
  3. Login to Azure

    azure login
    

    This will give you a code and prompt you to visit aka.ms/devicelogin. Provide the code and then login with your Azure identity (this may happen automatically if you're already logged in). You'll then be able to access your account via the CLI.

  4. Get your subcription and tenant id

    azure account show
    

    Save the subcription and tenant id for later

  5. Create a service principal for a given <name> and <password> and add contributor role.

    azure ad sp create -n <name> -p <password>
    

    This should return an object which has the servicePrincipalNames property on it and an ObjectId. Save the Object Id and one of the names in the array and the password you provided for later. If you need to look up your service principal later, you can use azure ad sp -c <name> where <name> is the name provided originally. Note that the <name> you provided is not the name you'll provide later, it is a name in the servicePrincipalNames array.

    Then grant the SP contributor access with the ObjectId

    azure role assignment create --objectId <objectIDFromCreateStep> -o Contributor
  6. Set up environment variables

    You need to set up environment variables for your subscription id, tenant id, service principal name, and password.

    # bash
    export azureSubId='<subscriptionId>'
    export azureServicePrincipalTenantId='<tenantId>'
    export azureServicePrincipalClientId='<servicePrincipalName>'
    export azureServicePrincipalPassword='<password>'
    # PowerShell
    $env:azureSubId='<subscriptionId>'
    $env:azureServicePrincipalTenantId='<tenantId>'
    $env:azureServicePrincipalClientId='<servicePrincipalName>'
    $env:azureServicePrincipalPassword='<password>'

3. Update the config in serverless.yml

Open up your serverless.yml file and update the following information:

service: my-azure-functions-app # Name of the Azure function App you want to create

4. Deploy, test, and remove your service

  1. Deploy a Service:

Use this when you have made changes to your Functions or you simply want to deploy all changes within your Service at the same time.

serverless deploy
  1. Deploy the Function:

Use this to quickly upload and overwrite your Azure function, allowing you to develop faster.

serverless deploy function -f httpjs
  1. Invoke the Function:

Invokes an Azure Function on Azure

serverless invoke --path httpQueryString.json -f httpjs
  1. Stream the Function Logs:

Open up a separate tab in your console and stream all logs for a specific Function using this command.

serverless logs -f httpjs -t
  1. Remove the Service: (optional)

Removes all Functions and Resources from your Azure subscription.

serverless remove

Contributing

Please create issues in this repo for any problems or questions you find. Before sending a PR for any major changes, please create an issue to discuss.

We're still in the process of getting everying running 100%, but please refer to the Serverless contributing guidlines for information on how to contribute and code of conduct.

License

MIT

serverless-azure-functions's People

Contributors

ac360 avatar itaym2 avatar lostintangent avatar pragnagopa avatar

Watchers

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