From bafb91ea4feea93e53672a48837284649ad4a361 Mon Sep 17 00:00:00 2001 From: sjuarezgx Date: Fri, 6 Dec 2024 13:54:41 -0300 Subject: [PATCH] Azure functions deploy changes (#119) Co-authored-by: Sabrina Juarez Garcia --- src/AzureFunctions/Templates/NET/blob.st | 26 +++ src/AzureFunctions/Templates/NET/cosmosdb.st | 26 +++ .../Templates/NET/eventgridazureschema.st | 26 +++ .../Templates/NET/eventgridcloudevents.st | 26 +++ src/AzureFunctions/Templates/NET/queue.st | 26 +++ .../Templates/NET/servicebusqueue.st | 27 +++ .../Templates/NET/servicebustopic.st | 27 +++ src/AzureFunctions/Templates/NET/timer.st | 26 +++ src/AzureFunctions/createpackage.msbuild | 160 +++++++++++++----- 9 files changed, 327 insertions(+), 43 deletions(-) create mode 100644 src/AzureFunctions/Templates/NET/blob.st create mode 100644 src/AzureFunctions/Templates/NET/cosmosdb.st create mode 100644 src/AzureFunctions/Templates/NET/eventgridazureschema.st create mode 100644 src/AzureFunctions/Templates/NET/eventgridcloudevents.st create mode 100644 src/AzureFunctions/Templates/NET/queue.st create mode 100644 src/AzureFunctions/Templates/NET/servicebusqueue.st create mode 100644 src/AzureFunctions/Templates/NET/servicebustopic.st create mode 100644 src/AzureFunctions/Templates/NET/timer.st diff --git a/src/AzureFunctions/Templates/NET/blob.st b/src/AzureFunctions/Templates/NET/blob.st new file mode 100644 index 0000000..90db7bb --- /dev/null +++ b/src/AzureFunctions/Templates/NET/blob.st @@ -0,0 +1,26 @@ +using GeneXus.Deploy.AzureFunctions.BlobHandler; +using GeneXus.Deploy.AzureFunctions.Handlers.Helpers; +using Microsoft.Azure.Functions.Worker; +using System.IO; + +namespace BlobTriggerFunctions +{ + $classes:{class | + public class $class.className$ + { + private ICallMappings _callmappings; + public $class.className$(ICallMappings callMappings) + { + _callmappings = callMappings; + \} + + [Function("$class.functionName$")] + public void Run([BlobTrigger("$class.blobPath$", Connection = "$class.connectionName$")] Stream blobItem, FunctionContext context) + { + BlobTriggerHandler function = new BlobTriggerHandler(_callmappings); + function.Run(blobItem, context); + \} + + \} + }$ +} \ No newline at end of file diff --git a/src/AzureFunctions/Templates/NET/cosmosdb.st b/src/AzureFunctions/Templates/NET/cosmosdb.st new file mode 100644 index 0000000..c91cc5d --- /dev/null +++ b/src/AzureFunctions/Templates/NET/cosmosdb.st @@ -0,0 +1,26 @@ +using GeneXus.Deploy.AzureFunctions.CosmosDBHandler; +using GeneXus.Deploy.AzureFunctions.Handlers.Helpers; +using Microsoft.Azure.Functions.Worker; +using System.Collections.Generic; + +namespace CosmosDBTriggerFunctions +{ + $classes:{class | + public class $class.className$ + { + private ICallMappings _callmappings; + public $class.className$(ICallMappings callMappings) + { + _callmappings = callMappings; + \} + + [Function("$class.functionName$")] + public void Run([CosmosDBTrigger(databaseName:"$class.databaseName$", containerName:"$class.containerName$", Connection = "$class.connectionName$", LeaseContainerName ="$class.leaseContainerName$",LeaseContainerPrefix ="$class.leaseContainerPrefix$",LeaseDatabaseName ="$class.leaseDatabaseName$",LeaseConnection ="$class.leaseConnection$")] IReadOnlyList> doc, FunctionContext context) + { + CosmosDBTriggerHandler function = new CosmosDBTriggerHandler(_callmappings); + function.Run(doc, context); + \} + + \} + }$ +} \ No newline at end of file diff --git a/src/AzureFunctions/Templates/NET/eventgridazureschema.st b/src/AzureFunctions/Templates/NET/eventgridazureschema.st new file mode 100644 index 0000000..63f91c2 --- /dev/null +++ b/src/AzureFunctions/Templates/NET/eventgridazureschema.st @@ -0,0 +1,26 @@ +using Azure.Messaging.EventGrid; +using GeneXus.Deploy.AzureFunctions.EventGridHandler; +using GeneXus.Deploy.AzureFunctions.Handlers.Helpers; +using Microsoft.Azure.Functions.Worker; + +namespace EventGridAzureSchemaFunctions +{ + $classes:{class | + public class $class.className$ + { + private ICallMappings _callmappings; + public $class.className$(ICallMappings callMappings) + { + _callmappings = callMappings; + \} + + [Function("$class.functionName$")] + public void Run([EventGridTrigger(IsBatched =true)] EventGridEvent[] events, FunctionContext context) + { + EventGridTriggerHandlerAzure function = new EventGridTriggerHandlerAzure(_callmappings); + function.Run(events, context); + \} + + \} + }$ +} \ No newline at end of file diff --git a/src/AzureFunctions/Templates/NET/eventgridcloudevents.st b/src/AzureFunctions/Templates/NET/eventgridcloudevents.st new file mode 100644 index 0000000..84bd9ef --- /dev/null +++ b/src/AzureFunctions/Templates/NET/eventgridcloudevents.st @@ -0,0 +1,26 @@ +using Azure.Messaging; +using GeneXus.Deploy.AzureFunctions.EventGridHandler; +using GeneXus.Deploy.AzureFunctions.Handlers.Helpers; +using Microsoft.Azure.Functions.Worker; + +namespace EventGridCloudEventFunctions +{ + $classes:{class | + public class $class.className$ + { + private ICallMappings _callmappings; + public $class.className$(ICallMappings callMappings) + { + _callmappings = callMappings; + \} + + [Function("$class.functionName$")] + public void Run([EventGridTrigger(IsBatched = true)] CloudEvent[] events, FunctionContext context) + { + EventGridTriggerHandlerCloud function = new EventGridTriggerHandlerCloud(_callmappings); + function.Run(events, context); + \} + + \} + }$ +} \ No newline at end of file diff --git a/src/AzureFunctions/Templates/NET/queue.st b/src/AzureFunctions/Templates/NET/queue.st new file mode 100644 index 0000000..1fa15c0 --- /dev/null +++ b/src/AzureFunctions/Templates/NET/queue.st @@ -0,0 +1,26 @@ +using Azure.Storage.Queues.Models; +using GeneXus.Deploy.AzureFunctions.Handlers.Helpers; +using GeneXus.Deploy.AzureFunctions.QueueHandler; +using Microsoft.Azure.Functions.Worker; + +namespace QueueTriggerFunctions +{ + $classes:{class | + public class $class.className$ + { + private ICallMappings _callmappings; + public $class.className$(ICallMappings callMappings) + { + _callmappings = callMappings; + \} + + [Function("$class.functionName$")] + public void Run([QueueTrigger("$class.queueName$", Connection = "$class.connectionName$")] QueueMessage queueMessage, FunctionContext context) + { + QueueTriggerHandler function = new QueueTriggerHandler(_callmappings); + function.Run(queueMessage, context); + \} + + \} + }$ +} \ No newline at end of file diff --git a/src/AzureFunctions/Templates/NET/servicebusqueue.st b/src/AzureFunctions/Templates/NET/servicebusqueue.st new file mode 100644 index 0000000..3e6ab9c --- /dev/null +++ b/src/AzureFunctions/Templates/NET/servicebusqueue.st @@ -0,0 +1,27 @@ +using System.Threading.Tasks; +using Azure.Messaging.ServiceBus; +using GeneXus.Deploy.AzureFunctions.Handlers.Helpers; +using GeneXus.Deploy.AzureFunctions.ServiceBusHandler; +using Microsoft.Azure.Functions.Worker; + +namespace ServiceBusQueueFunctions +{ + $classes:{class | + public class $class.className$ + { + private ICallMappings _callmappings; + public $class.className$(ICallMappings callMappings) + { + _callmappings = callMappings; + \} + + [Function("$class.functionName$")] + public async Task Run([ServiceBusTrigger("$class.queueName$", Connection = "$class.connectionName$", IsBatched = true, IsSessionsEnabled=$class.sessionEnabled$)] ServiceBusReceivedMessage[] receivedMessages, FunctionContext context) + { + ServiceBusTriggerHandler function = new ServiceBusTriggerHandler(_callmappings); + await function.Run(receivedMessages, context); + \} + + \} + }$ +} \ No newline at end of file diff --git a/src/AzureFunctions/Templates/NET/servicebustopic.st b/src/AzureFunctions/Templates/NET/servicebustopic.st new file mode 100644 index 0000000..e0b7a91 --- /dev/null +++ b/src/AzureFunctions/Templates/NET/servicebustopic.st @@ -0,0 +1,27 @@ +using System.Threading.Tasks; +using Azure.Messaging.ServiceBus; +using GeneXus.Deploy.AzureFunctions.Handlers.Helpers; +using GeneXus.Deploy.AzureFunctions.ServiceBusHandler; +using Microsoft.Azure.Functions.Worker; + +namespace ServiceBusQueueFunctions +{ + $classes:{class | + public class $class.className$ + { + private ICallMappings _callmappings; + + public $class.className$(ICallMappings callMappings) + { + _callmappings = callMappings; + \} + + [Function("$class.functionName$")] + public async Task Run([ServiceBusTrigger("$class.topicName$","$class.subscriptionName$", Connection = "$class.connectionName$", IsBatched = true, IsSessionsEnabled=$class.sessionEnabled$)] ServiceBusReceivedMessage[] receivedMessages, FunctionContext context) + { + ServiceBusTriggerHandler function = new ServiceBusTriggerHandler(_callmappings); + await function.Run(receivedMessages, context); + \} + \} + }$ +} \ No newline at end of file diff --git a/src/AzureFunctions/Templates/NET/timer.st b/src/AzureFunctions/Templates/NET/timer.st new file mode 100644 index 0000000..dd8ebe1 --- /dev/null +++ b/src/AzureFunctions/Templates/NET/timer.st @@ -0,0 +1,26 @@ +using Microsoft.Azure.Functions.Worker; +using GeneXus.Deploy.AzureFunctions.Handlers.Helpers; +using GeneXus.Deploy.AzureFunctions.TimerHandler; + +namespace TimerTriggerFunctions +{ + $classes:{class | + public class $class.className$ + { + private ICallMappings _callmappings; + public $class.className$(ICallMappings callMappings) + { + _callmappings = callMappings; + \} + + [Function("$class.functionName$")] + + public void Run([TimerTrigger("$class.timerSchedule$")] TimerInfo timerInfo, FunctionContext context) + { + TimerTriggerHandler function = new TimerTriggerHandler(_callmappings); + function.Run(timerInfo, context); + \} + + \} + }$ +} \ No newline at end of file diff --git a/src/AzureFunctions/createpackage.msbuild b/src/AzureFunctions/createpackage.msbuild index 4b6b8d2..7748cee 100644 --- a/src/AzureFunctions/createpackage.msbuild +++ b/src/AzureFunctions/createpackage.msbuild @@ -1,25 +1,98 @@ - $([System.IO.Path]::GetFullPath('$(DeployFullPath)\..\..\..\..\web\$(ProjectName).gxdproj')) + $([System.IO.Path]::GetFullPath('$(DeployFullPath)/../../../../web/$(ProjectName).gxdproj')) - + $(DeployFullPath) - $(GX_PROGRAM_DIR)\DeploymentTargets\AzureFunctions\AzFunctionFiles\bin - $(GX_PROGRAM_DIR)\DeploymentTargets\AzureFunctions\AzFunctionFiles\src - $(DeployFullPath)\src\build + $(GX_PROGRAM_DIR)/DeploymentTargets/AzureFunctions/AzFunctionFiles/bin + $(GX_PROGRAM_DIR)/DeploymentTargets/AzureFunctions/AzFunctionFiles/src + $(DeployFullPath)/src/build - - + + - + + + + + + + + $(AZURE_FUNCTIONS_TRIGGER_TYPE) + $(AZURE_FUNCTIONS_SERVICEBUS_TYPE) + $(AZURE_FUNCTIONS_SERVICEBUS_QUEUENAME) + $(AZURE_FUNCTIONS_SERVICEBUS_CONNECTION) + $(AZURE_FUNCTIONS_SERVICEBUS_ISSESSIONENABLED) + + + $(AZURE_FUNCTIONS_TRIGGER_TYPE) + $(AZURE_FUNCTIONS_SERVICEBUS_TOPICNAME) + $(AZURE_FUNCTIONS_SERVICEBUS_SUBSCRIPTIONNAME) + $(AZURE_FUNCTIONS_SERVICEBUS_CONNECTION) + $(AZURE_FUNCTIONS_SERVICEBUS_ISSESSIONENABLED) + + + + + + $(AZURE_FUNCTIONS_TRIGGER_TYPE) + $(AZURE_FUNCTIONS_SCHEDULE_TIME) + %$(AZURE_FUNCTIONS_SCHEDULE_TIME_APPSETTINGNAME)% + + + + + + $(AZURE_FUNCTIONS_TRIGGER_TYPE) + $(AZURE_FUNCTIONS_QUEUE_NAME) + $(AZURE_FUNCTIONS_QUEUE_CONNECTION) + + + + + + $(AZURE_FUNCTIONS_TRIGGER_TYPE) + $(AZURE_FUNCTIONS_BLOB_STORAGE_PATH) + $(AZURE_FUNCTIONS_BLOB_STORAGE_CONNECTION) + + + + + + $(AZURE_FUNCTIONS_TRIGGER_TYPE) + $(AZURE_FUNCTIONS_EVENTGRID_SCHEMA) + + + + + + $(AZURE_FUNCTIONS_TRIGGER_TYPE) + $(AZURE_FUNCTIONS_COSMOSDB_DATABASE_APPSETTINGVALUE) + $(AZURE_FUNCTIONS_COSMOSDB_CONTAINER_APPSETTINGVALUE) + $(AZURE_FUNCTIONS_COSMOSDB_CONNECTION) + $(AZURE_FUNCTIONS_COSMOSDB_LEASE_DATABASE) + $(AZURE_FUNCTIONS_COSMOSDB_LEASE_CONTAINER) + $(AZURE_FUNCTIONS_COSMOSDB_LEASE_CONTAINER_PREFIX) + $(AZURE_FUNCTIONS_COSMOSDB_LEASE_CONNECTION) + + + + + DeployFullPath="$(DeployFullPath)" + GeneratorId = "$(Generator)" /> @@ -97,61 +171,61 @@ + DestinationFolder="$(DeploySrcBuildPath)/GeneXus.Deploy.AzureFunctions.Handlers/%(RecursiveDir)" SkipUnchangedFiles="true" /> - - + - + - + - - - - - - - - - - + + + + + + + + + + - + - + %(ModuleRelPathLower.Identity) - + - + - + + DestinationFiles="@(CacheMetadata -> '$(DeployFullPath)/bin/Metadata/TableAccess/%(Filename)%(Extension)')" SkipUnchangedFiles="true" /> + DestinationFiles="@(PrivateDirectory -> '$(DeployFullPath)/bin/private/%(Filename)%(Extension)')" SkipUnchangedFiles="true" /> + DestinationFiles="@(ConfResources -> '$(DeployFullPath)/bin/%(Filename)%(Extension)')" SkipUnchangedFiles="true" /> @@ -162,11 +236,11 @@ - + - - + + @@ -175,13 +249,13 @@ - + - + @@ -191,8 +265,8 @@ - - + + @@ -209,22 +283,22 @@