This example demonstrates how to use Durable Functions to send a confirmation email via SMTP(Example using gmail). The user has 15 minutes to confirm or deny the email by clicking a link. The link in the email contains a code that is validated server side to ensure it was a valid click. This could easily be implemented to integrate within registration for a website or application.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- Visual Studio 2017
- Azure Functions and Web Jobs Tools Visual Studio Extension
- Azure Storage Emulator
- CURL or PostMan
Clone the repository to your local machine
Open in Visual Studio and add a local.settings.json file with the following contents:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"DisplayName": "John Smith",
"SMTPUsername": "yoursmtpuser@gmail.com",
"SMTPPassword": "smtppassword",
"SMTPHost": "smtp.gmail.com",
"SMTPPort": "587"
}
}
Note: If you are using Gmail then you need to do the following:
- Sign into Gmail.
- Go to the “Less secure apps” section in My Account.
- Next to “Allow less secure apps: OFF,” select the toggle switch to turn on. (Note to G Suite users: This setting is hidden if your administrator has locked less secure app account access.)
Run the project in Visual Studio and make a request using your favorite tool like PostMan or CURL
POST http://localhost:7071/api/orchestrators/RequestApproval
{
"Requestor": {
"FirstName": "CJ",
"LastName": "van der Smissen"
},
"Email": "test@test.com"
}
- Right click the project and select Publish
- Follow the prompts to publish in Azure
- Login to Azure Portal and update the application settings to the appropriate values you previously used in local.settings.json
- Azure Functions - Platform
- Durable Task - Framework
- AzureFunctions.Autofac - Dependency Injection
- CJ van der Smissen - Initial work - Intro to Computer Science
See also the list of contributors who participated in this project.
This project is licensed under the GPL License - see the LICENSE.md file for details
- Thanks to Paco de la Cruz for an initial outline of Approval Workflow using SendGrid