A framework for simplifying azure functions.
- Very simple setup of full-featured Azure functions, allowing you to focus on your work instead of setup.
- Automatic HTTP request parsing through your own custom parameter class. Generates helpful error messages with input parameters are wrong.
- Automatic generation of Swagger documentation
- Smart error handling
- Simplified Azure keyvault access
- Support for data binding
- Better support for timer triggers
- Better Swagger output UI
(A very simple example can be found here.)
- Using visual studio, create two projects:
a. An Azure functions project to expose your endpoints b. A Class library for your implementation code. - Link your projects against The AFRocketScience Nuget package
- Create your handler code in the class library project a. First argument is a custom type that has parameters you care about. b. Second argument is an ISessionLogger c. Don't worry about error handling. Just write code to do the job. RocketScience will handle the details!
- Create an Azure endpoint. a. Add a Handler property to expose your handler class b. Call LaunchPad.ExecuteHttpTrigger() - RocketScience with automatically pull parameters out of the request and call your handler with them.
Roughly:
public class MyHandler
{
public class MyArguments
{
public bool IsOver9000 { get; set; }
public string FlubberBus {get; set;}
public string[] FishTypes { get; set; }
}
public string[] GetStuff(MyArguments args, IServiceLogger log)
{
return new [] { args.FishTypes }
}
}
public static class MyServiceApi
{
public static MyHandler Handler { get; set; } = new MyHandler();
[FunctionName("GetStuff")]
public static async Task<HttpResponseMessage> GetStuff(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "v1/getstuff")]
HttpRequestMessage req,
TraceWriter log)
{
return await LaunchPad.ExecuteHttpTrigger(req, new TraceLogger(log));
}
}
- Your app needs a registered app identity which you create inside Azure portal.
- Open App registrations in Azure Portal
- Click 'New application registration'
- Create your own self-signed certificate
- Instructions later
- Export public key
- Attach the cert to the registered app identity
- Open App registrations in Azure Portal
- Click on your app registration
- Go to Settings-> Keys-> Upload Public Key
- Upload your cert public key
- Create a KeyVault
- Add your app Id as an authorized key vault user
- Add secrets to you keyvault