Giter Club home page Giter Club logo

fta-live-serverless-with-function-sample's Introduction

Weather Station

Weather Station is a Function App sample that demonstrates some basic features of Azure Functions

Features

This projects demonstates the following features:

  • Integration with other Azure PaaS services (Event Hubs, Azure Cosmos DB, Event Grid)
  • Using managed identities in Azure Functions.
  • Monitoring Azure Functions using Application Insights.
  • Creating Azure Function resources using Bicep.
  • Deploy the infrastructure and code for our Azure Function using GitHub Actions.

Prerequisites

  • An Azure Subscription
  • The lastest Azure CLI version installed.
  • Fork this GitHub repository in your own account and with the capability of executing GitHub actions (public repository is needed for this).
  • Azure Function Core Tools (Optional. Only needed if deploying the resources manually).

Deploy

Option 1: Using GitHub Actions

  1. In a command prompt or in the Azure Cloud Shell, define the following environment variables:
RESOURCE_GROUP=<name-of-resource-group>
LOCATION=<azure-region-near-you>
  1. Login to your Azure Subscription and set the subscription that you want to use for this sample:
az login
az account list -o table
az account set -n <your-subscription-id>
  1. Create a resource group for our sample:
az group create --name $RESOURCE_GROUP --location $LOCATION
  1. Create a Service Principal and give it acess to the resource group
az ad sp create-for-rbac --name <name-of-your-service-principal> --role Contributor --scopes <id-of-your-resource-group> --sdk-auth
  1. This command will generate a JSON output. Copy the full output.
  2. In your GitHub Repository, navigate to Settings > Secrets and select New Repository Secret.
  3. Name the secret AZURE_CREDENTIALS and paste the output into the value textbox.
  4. Create a new secret called AZURE_RG and type in the name of your resource group that you've created as the value.
  5. Create a new secret called AZURE_SUBSCRIPTION and enter your Azure Subscription Id as the value.
  6. In your GitHup Repository, navigate to Actions and select the Deploy Sample action.
  7. Select Run workflow > Run workflow
  8. This will start a new workflow that will deploy the necessary infrastructure and functions code in this sample.
  9. Navigate to the Azure Portal and ensure that all resources have been correctly deployed.

Option 2: Deploy manually

To deploy the infrastructure required for this sample straight to your Azure Subscription, click the button below:

Deploy to Azure

To deploy the Functions to your Function App, navigate to the src folder in the cloned or forked repository and run the following command:

func azure functionapp publish <FunctionAppName>

Set up Event Grid Trigger

To configure the Event Grid Trigger function, we need to setup the following Event Subscription manually. In the storage account that has been created, click on Events. Click on + Event Subscription to create a new Event Subscription:

The Events icon in the Storage Account sidebar menu

In the Basics tab, configure the following settings:

  • Under Event Subscription Details, give your subscription a name and set the Event Schema to Event Grid Schema.
  • Under Topic Details, give your System Topic a name.
  • Under Event Types, filter the Event Types to Blob Created.
  • Under Endpoint Details, select the ProcessWeatherFileEventGrid function in your deployed Function App.

Basic configuration for Storage Account event

In the Filters tab, enable subject filtering. As part of our infrastructure deployment, we created two blob containers to upload files to trigger Functions in our Function App. For our Event Grid Function, we will only trigger that function based on new files being uploaded to our eventgridtriggercontainer.

In the Subject Begins With textbox, enter the name of your Storage Account followed by eventgridtriggercontainer in the following format:

<storage-account-name>/eventgridtriggercontainer

Adding filtering on our Storage Account event

Licence

This project is licensed under the MIT License - see the LICENSE file for details.

fta-live-serverless-with-function-sample's People

Contributors

willvelida avatar

Watchers

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