This repository contains Azure Functions sample code. They can easily be loaded by setting up Continuous Integration to your own source code repository. For each example the relevant connections will need to be set up manually in the "Integrate" tab of the function app.
This blob trigger will perform an in-memory root level extraction of a ZIP archive.
- Increase Memory Size in Function App Settings for larger ZIP files
- This example code only extracts the root folder of the ZIP file
- Destination is set to the same container that triggers the code
This HTTP trigger shows examples of how to access the requested uri, headers and querystring. It checks for the existence of a 'name' query string parameter and, if present, will output it in the response.
This timer trigger every minute loads a PowerShell script that runs an .exe file. This executable is placed with the function; a simple console app that just posts a line to the log. Code below:
using System;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
This queue trigger will append the queue message to a text file. A valid storage account Name and Key need to be put in this example code. Also the example "logs" container needs to be present in that account.
- Azure Functions does not support AppendBlobs out-of-the-box; related methods are missing
- To solve this a NuGet package of WindowsAzure.Storage is loaded via project.json
- This code uses AppendBlock over AppendText, because the latter does not support concurrent writes
This blob trigger will perform an image resize using the NuGet package ImageResizer.
- It demonstrates directly interacting with an input stream and an output stream
- The project.json file is required to load the NuGet package
This timer trigger will execute a SQL Stored Procedure every 5 minutes. This timing is dictated by the Cron expression in Schedule on the Integrate tab.
In this particular example, DeleteExpiredSessions is called which cleans up expired session state of Sitecore on Azure SQL databases. Azure SQL does not have a SQL Agent running to do this job. [note: untested]
The SQL connection string (named "ASPState" in this example) can be set using Function App Settings -> Go to App Service Settings -> Application Settings -> Connection Strings.