View CosmosDb.OutputBinding.V2.cs
[FunctionName("ProductUpsertHttpTrigger")]
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "products")] HttpRequest req,
[CosmosDB(
databaseName: "%CosmosDbDdatabaseName%",
collectionName: "%CosmosDbCollectionName%")] IAsyncCollector<Product> collector,
View CosmosDb.OutputBinding.V1.cs
[FunctionName("ProductUpsertHttpTrigger")]
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "products")] HttpRequestMessage req,
[DocumentDB(
databaseName: "%CosmosDbDdatabaseName%",
collectionName: "%CosmosDbCollectionName%")] IAsyncCollector<Product> collector,
View CosmosDb.Trigger.cs
...
using Microsoft.Azure.Documents;
...
namespace CosmosDb.NetFramework.FunctionApp
{
public static class UpsertProductCosmosDbTrigger
{
[FunctionName("ProductUpsertCosmosDbTrigger")]
public static void Run(
View LogicApp.Compose.json
"Compose": {
"type": "Compose",
"inputs": {
"input": "@{triggerBody()?['input']}",
// WDL function to convert time zone.
"logicAppOutput": "@{convertTimeZone(triggerBody()?['input'], 'UTC', 'AUS Eastern Standard Time', 'o')}",
// Time zone conversion from Azure Function
"functionOutput": "@{body('HTTP')?['output']}"
View TimeZoneConverterHttpTrigger.cs
[FunctionName("TimeZoneConverterHttpTrigger")]
public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = "convert/timezone")]HttpRequest req, TraceWriter log)
{
// Suppress Date/Time string to be converted to DateTime object.
var settings = new JsonSerializerSettings() { DateParseHandling = DateParseHandling.None };
dynamic body = JsonConvert.DeserializeObject(await req.ReadAsStringAsync().ConfigureAwait(false), settings);
var input = (string)body?.input;
var utc = DateTimeOffset.TryParse(input, null, DateTimeStyles.AssumeUniversal, out DateTimeOffset result)
View Invoke-Pester.ps1
$params = @{ LogicAppName1 = "my-new"; LogicAppName2 = "logic-app" }
$parameters = @{ ResourceGroupName = "my-resource-group"; TemplateFile = ".\LogicApp.json"; Parameters = $params }
$script = @{ Path = ".\LogicApp.Tests.ps1"; Parameters = $parameters }
Invoke-Pester -Script $script
View LogicApp.Tests.ps1
Param(
[string] [Parameter(Mandatory=$true)] $ResourceGroupName,
[string] [Parameter(Mandatory=$true)] $TemplateFile,
[hashtable] [Parameter(Mandatory=$true)] $Parameters
)
Describe "Logic App Deployment Tests" {
BeforeAll {
$DebugPreference = "Continue"
}
View Output-Json.ps1
($output[32] -split "Body:")[1] | ConvertFrom-Json
View Test-AzureRmResourceGroupDeployment-DebugOutput.ps1
$DebugPreference = "Continue"
$output = Test-AzureRmResourceGroupDeployment `
-ResourceGroupName my-resource-group `
-TemplateFile .\LogicApp.json `
-logicAppName1 my-new `
-logicAppName2 logic-app `
-ErrorAction Stop `
5>&1
View Test-AzureRmResourceGroupDeployment-Debug.ps1
$DebugPreference = "Continue"
Test-AzureRmResourceGroupDeployment `
-ResourceGroupName my-resource-group `
-TemplateFile .\LogicApp.json `
-logicAppName1 my-new `
-logicAppName2 logic-app `
-ErrorAction Stop
$DebugPreference = "SilentlyContinue"