This is a small starter project for building azure functions.
It includes:
- A robust configuration architecture:
- manage configurations in your app settings with
someThing-Specific
and get maps for accessing throughout the app - Ability to control configuration from app settings or code
- manage configurations in your app settings with
- Loads of common utilities:
- Http utilities for POST and GET
- SAS token generation
- time converters, a promiseified
delay
, asyncforEach
- sql utility complete with stored procedure options
- Promise-ified azure storage utilities for use with
async
/await
- Application insights added and sprinkled throughout
- Types of triggered functions
- HttpTrigger
- QueueTrigger
- TimerTrigger
- A webhook debugger
- Code Quality
- linter
- unit tests
This contains these functions:
- HttpTriggerInvokeProcedure
- HttpTriggerJob
- QueueTriggeredJob
- HttpWebhookDebugger
- TimerTrigger
This accepts an http trigger. Code exists for using http to send a message to a queue.
Commented-out code shows sends a message to a queue. This is configured in config/queues.config.js
.
This is triggered by an HTTP POST request. This is configured in HttpTriggeredJob/function.json
. The in-bound binding is named req
. The outbound binding is named res
.
The body of this http request is expected to be JSON.
Add your documentation here
This receives a message from a queue.
Add your documentation here.
Add your documentation here.
This is a a function that can trigger a stored procedure.
The body could look like this
{
"callbackUrl": "somewhere.com"},
"processInputParameters": {
"outputBlobName": "data",
"outputReportNames": "folder/file.json"
},
"processPlatform": "somePlatform"
}
It will generate a SAS key to access the blob, and it will then trigger a stored procedure on the blob. It will return a 202
if successful.
{
"processInputParameters": {
"outputReportNames": "folder/file.json",
"outputBlobName": "data"
},
"processPlatform": "somePlatform"
}
This runs on a timer. The timing interval is defined in the function.json. It's a cron job.
This is solely for functions that use a webhook. In any case where a webhook needs callback url - or you need to test a POST request, you can use this.
The webhook debugger takes a JSON body and returns it back.
-
Within Visual Studio Code, install the following extensions:
- Azure Tools
- Azure Logic Apps
- Azure Functions
-
Install the Azure CLI
-
Within VS Code, open this directory - not the parent folder. (If you set the parent folder as your workspace directory, it will try to install Azure Functions settings files)
-
Open a terminal in VS Code (ctrl + ` )
-
Install npm packages with
npm install
-
Press
F5
. A debugging terminal will open -
After the debugging terminal opens, it will display something like the following:
HttpTriggeredInvokeProcedure: [GET,POST] http://localhost:7071/api/HttpTriggeredInvokeProcedure HttpTriggerJob: [GET,POST] http://localhost:7071/api/HttpTriggerJob HttpWebhookDebugger [POST ] http://localhost:7071/api/HttpWebhookDebugger
ctrl + click
the link. Your default browser will open and the azure function will execute locally. You are now able to add any necessary breakpoints within the application.
Note If you want to run .net core apps and this node.js azure function together, you will need to change the ports in one of the two projects.
The following keys must have values in order to run the app locally:
AzureWebJobsStorage
ORAZURE_STORAGE_CONNECTION_STRING
You can acquire these values from a portal administrator or an existing function app. When the app runs, these are added to process.env
.
User should be able to deploy from within VSCode. Click on the Azure button in the left side of the IDE screen. In the Functions pane, select an existing app, or create a new one to deploy to.
Application settings need to be added/updated in the azure portal.
- Go to the function app in the portal.
- Click "Function App Settings"
- Click "manage application settings"
The following keys must be present and have values.
AzureWebJobsStorage
sasAccessKey
sqlPassword