Giter Club home page Giter Club logo

codercardsv2's Introduction

CoderCards - Class Libary Version

This is a precompiled function version of the Azure Functions sample CoderCards.

About the sample

  • This sample uses the new precompiled function feature. The project also uses WebJobs attributes instead of function.json. Use the FunctionName attribute to provide the name that will appear in the portal.

  • There are two versions of the project:

    • CoderCards.csproj, which requires Visual Studio 2017 Update 3 and the Azure Functions Tools VSIX. When the project is built, the file function.json is generated in the build output folder.
    • CoderCardsWebProj.csproj, which is a regular web project. To convert attributes to function.json, it runs Runner.exe as a post-build step. To make the project runnable with F5, you must modify the project start action to launch the Azure Functions Core Tools. (See intructions below.)
  • There are two functions defined in this project:

    • RequestImageProcessing. HTTP trigger that writes a queue message. The request payload must be in the following form:
        {
          "PersonName": "Scott Guthrie",
          "Title": "Red Polo Connoisseur",
          "BlobName": "Scott Guthrie-Red Polo Connoisseur.jpg"
        }
    • GenerateCard. Queue trigger that binds to the blob specified in the BlobName property of the queue payload. Based on the predominant emotion of the input image, it generates a card using one of 4 card templates.

      • The card is written to the output blob container specified by the app setting output-container.

Required App Settings

Key Description
AzureWebJobsStorage Storage account connection string
EmotionAPIKey Key for Cognitive Services Emotion API
input-queue Name of Storage queue for to trigger card generation. Use a value like "local-queue" locally and "input-queue" on Azure
input-container Name of Storage container for input images. Use a value like "local-card-input" locally and "card-input" on Azure
output-container Name of Storage container for output images. Use a value like "local-card-output" locally and "card-output" on Azure
HOME Set to "." when running locally. Is automatically set on Azure
SITE_PATH Use "." when running locally. Use site\\wwwroot on Azure

Local debugging in Visual Studio

  • If you're using Visual Studio 2017 Update 3 and the Azure Functions Tools VSIX, open the project CoderCards.csproj. F5 will automatically launch the Azure Functions Core tools.

  • If you're using CoderCardsWebProj.csproj, you must customize the project start action to launch the Azure Functions Core tools. See screenshot below.

    1. Install the Azure Functions Core Tools from npm.
    2. Right-click CoderCardsWebProj and open Properties.
    3. In the Web tab, choose Start External Program
    4. For the program path, enter the path to func.exe for the Azure Functions CLI. The path will be similar to like C:\Users\USERNAME\AppData\Roaming\npm\node_modules\azure-functions-cli\bin\func.exe
    5. For Command line arguments set host start --cors *
    6. For Working directory, specify the root of the project CoderCardsWebProj on your machine.

    Start external program settings

Running the demo

Running using the provided SPA webpage

TBD

Running manually

  1. Choose images that are square and upload to the card-input container.

  2. Send an HTTP request using Postman or CURL, specifying the path of the blob you just uploaded:

    {
      "PersonName": "My Name", 
      "Title": "My Title",
      "BlobName": "BlobFilename.jpg"
    }

Notes

Talking points about Azure Functions

  • Creating an HTTP trigger that writes a queue message is just one line of code!

  • Using a queue message to trigger blob processing is preferable to a blob trigger, as it is easier to ensure transactional processing. Also, blob triggers can be delayed for up to 10 minutes on the Consumption plan.

  • By binding to a POCO, you can use the payload of a trigger to configure an input binding. In this example, we binding to the BlobName property in the queue message.

  • The input binding is just a byte array, which makes it easy to manipulate with memory streams (no need to create new ones). Other binding types for C# are Stream, CloudBlockBlob, etc, which is very flexible. The output binding is just a stream that you just write to.

codercardsv2's People

Contributors

btardif avatar lindydonna avatar sergeyza avatar

Watchers

 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.