Giter VIP home page Giter VIP logo

azuresample-jokesapi's Introduction

Joke Generator

HTTP Azure Function that returns random jokes. Based off this version built in JavaScript

Run locally via Command Line

  1. Install Azure Functions Core Tools

  2. Clone this repository and navigate to its directory in your favorite command line tool

  3. In the command line run the following

     `jokes-api > func start`
    
  4. You should see something like this:

    Now listening on: http://0.0.0.0:7071
    Application started. Press Ctrl+C to shut down.
    
    Functions:
    
            jokes-api: [GET,POST] http://localhost:7071/api/jokes-api
    
    For detailed output, run func with --verbose flag.
    [2021-01-22T19:06:20.689] Worker process started and initialized.
    
  5. Test it out with Postman

Deploy to Azure via VS Code

FYI: There are MANY ways to deploy a function to Azure, you can find more info here

  1. Open your local copy in VS Code

  2. Install the Azure Function Extension

  3. In the Explorer, right click in the root directory and select Deploy to Function App...

  4. Follow the prompts that pop up at the top of the editor

    • ⚠ You may be asked to sign in to your Azure account first
  5. You should see a "Deploying to [your function app name]" notification, and will changes to "Deployment to [your function app name] completed" when finished.

  6. Open the Azure Extension and search for your function app at [your function app name]. Confirm the jokes-api function exists

    • ⚠ If not, try deploying again to [your function app name]
  7. Right click on the jokes-api function and select Copy function Url

  8. Test it out with Postman

It should look something like this:

sending a get request with postman

Testing with Postman

Postman makes it easy to send POST/GET/etc requests to endpoints, perfect for HTTP triggered functions! Download it here: Postman download page

Testing a Local Function

  • In Postman, click Import and find the collection in the repo named AzureSamples.postman_collection.json found here
  • In the AzureSamples, collection open Local - JokesAPIRequest
  • Confirm that the url matches the one from step 4
    • ⚠ if they're not the same use the url that was generated on your machine!
  • Click Send

Testing a Deployed Function

  • In Postman, click Import and find the collection in the repo named AzureSamples.postman_collection.json found here
  • In the AzureSamples, collection open JokesAPIRequest
  • Paste the copied url from step 7, replacing the placeholder url
  • Click Send

It should look something like this:

sending a get request with postman

📖 Learn more about Azure Functions 👩🏿‍🏫 Microsoft Learn Modules on Azure Functions

azuresample-jokesapi's People

Contributors

azureadvocatebit avatar paladique avatar

Stargazers

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