HTTP Azure Function that returns random jokes. Based off this version built in JavaScript
-
Install Azure Functions Core Tools
-
Clone this repository and navigate to its directory in your favorite command line tool
-
In the command line run the following
`jokes-api > func start`
-
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.
-
Test it out with Postman
FYI: There are MANY ways to deploy a function to Azure, you can find more info here
-
Open your local copy in VS Code
-
Install the Azure Function Extension
-
In the Explorer, right click in the root directory and select
Deploy to Function App...
-
Follow the prompts that pop up at the top of the editor
- ⚠ You may be asked to sign in to your Azure account first
-
You should see a "Deploying to [your function app name]" notification, and will changes to "Deployment to [your function app name] completed" when finished.
-
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]
-
Right click on the
jokes-api
function and selectCopy function Url
-
Test it out 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
- In Postman, click
Import
and find the collection in the repo namedAzureSamples.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
- In Postman, click
Import
and find the collection in the repo namedAzureSamples.postman_collection.json
found here - In the AzureSamples, collection open
JokesAPIRequest
- Paste the copied url from step 7, replacing the placeholder url
- Click
Send
📖 Learn more about Azure Functions 👩🏿🏫 Microsoft Learn Modules on Azure Functions