Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to HTTP Azure functions due to implementation of MVC rest controllers #125

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/AzureFunctions/http/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ItemGroup Condition="'$(MSBuildProjectName)' == 'GeneXus.Programs.Common'">
<Reference Update="GeneXus.dll">
<HintPath>../../GeneXus.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(MSBuildProjectName)' != 'GeneXus.Deploy.AzureFunctions.Handlers' AND '$(MSBuildProjectName)' != 'GeneXus.Programs.Common' AND '$(MSBuildProjectName)' != 'GxWebStartup'">
<Reference Update="GeneXus.dll">
<HintPath>../../GeneXus.dll</HintPath>
</Reference>
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.4" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.23.0" />
<ProjectReference Include="..\GeneXus.Deploy.AzureFunctions.Handlers\GeneXus.Deploy.AzureFunctions.Handlers.csproj" />
</ItemGroup>
</Project>

59 changes: 51 additions & 8 deletions src/Common/Azure/azurefunctions-create-NETpackage.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<DeploymentTargetBinPath>$(GX_PROGRAM_DIR)\DeploymentTargets\AzureFunctions\AzFunctionFiles\bin</DeploymentTargetBinPath>
<DeploymentTargetSrcPath>$(GX_PROGRAM_DIR)\DeploymentTargets\AzureFunctions\AzFunctionFiles\src</DeploymentTargetSrcPath>
<DeploySrcBuildPath>$(DeployFullPath)\src\build</DeploySrcBuildPath>
<DeploySrcWebPath>$(DeployFullPath)/src/web</DeploySrcWebPath>
<AzureFunctionsHandlerProject>GeneXus.Deploy.AzureFunctions.Handlers.csproj</AzureFunctionsHandlerProject>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,19 +18,34 @@
</ItemGroup>

<Target Name="CreateNETPackage" DependsOnTargets="ValidatePackaging;NETpackageZipDeploy" Condition="'$(NETGenerator)' == 'true'"/>

<Target Name="CopyAzureBinaries" Condition="'$(DeployType)'!='SOURCES' AND '$(NETGenerator)' == 'true'">

<Target Name="TransformMVCToAzureFunctions" Condition="'$(NETGenerator)' == 'true' AND '$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'http'">
<!-- Transform MVC of rest services to Azure functions -->
<Message Text="Convert MVC Services to Azure Functions..." Importance="high" />
<GenerateAzHTTPFunctionFromMVC
serviceSourcePath="$(DeploySrcWebPath)"
/>
</Target>

<Target Name="AddAzureHandlersSources" Condition="'$(DeployType)'=='SOURCES' AND '$(NETGenerator)' == 'true'" DependsOnTargets="TransformMVCToAzureFunctions">
<Message Text="Adding Azure Functions Handlers sources to $(DeploymentUnit).sln" Importance="high" ></Message>

<PropertyGroup>
<AzureFunctionsHandlerProject>GeneXus.Deploy.AzureFunctions.Handlers.csproj</AzureFunctionsHandlerProject>
</PropertyGroup>
<Copy SourceFiles="@(AzureFunctionsRootSrc)"
DestinationFolder="$(DeployFullPath)/src/build/GeneXus.Deploy.AzureFunctions.Handlers/%(RecursiveDir)" SkipUnchangedFiles="true" />

<Copy SourceFiles="$(DeployAppDir)/functions.metadata"
DestinationFolder="$(DeployFullPath)/src/build/GeneXus.Deploy.AzureFunctions.Handlers" SkipUnchangedFiles="true" Condition="Exists('$(DeployAppDir)/functions.metadata')"/>

<Exec Command="dotnet sln $(DeploymentUnit).sln add &quot;$(DeploySrcBuildPath)/GeneXus.Deploy.AzureFunctions.Handlers/GeneXus.Deploy.AzureFunctions.Handlers.csproj&quot;" WorkingDirectory="$(DeploySrcBuildPath)" />
</Target>

<Target Name="BuildAzureHandlersSources" Condition="'$(DeployType)'!='SOURCES' AND '$(NETGenerator)' == 'true' AND '$(AZURE_FUNCTIONS_TRIGGER_TYPE)' != 'http'">

<PropertyGroup>
<CosmosDBSupport Condition="'$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'cosmosdb'">true</CosmosDBSupport>
<TimerSupport Condition="'$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'timer'">true</TimerSupport>
<AzureQueueSupport Condition="'$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'queue'">true</AzureQueueSupport>
<ServiceBusSupport Condition="'$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'servicebus'">true</ServiceBusSupport>
<HttpSupport Condition="'$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'http'">true</HttpSupport>
<BlobSupport Condition="'$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'blobstorage'">true</BlobSupport>
<EventGridSupport Condition="'$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'eventgrid'">true</EventGridSupport>
</PropertyGroup>
Expand All @@ -45,6 +62,31 @@

</Target>

<Target Name="BuildAzureHandlersSourcesHTTP" Condition="'$(DeployType)' != 'SOURCES' AND '$(NETGenerator)' == 'true' AND '$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'http'" DependsOnTargets="TransformMVCToAzureFunctions">

<PropertyGroup>
<HttpSupport Condition="'$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'http'">true</HttpSupport>
</PropertyGroup>

<Copy SourceFiles="@(AzureFunctionsRootSrc)"
DestinationFolder="$(DeployFullPath)/src/build/GeneXus.Deploy.AzureFunctions.Handlers/%(RecursiveDir)" SkipUnchangedFiles="true" />

<Copy SourceFiles="$(DeployAppDir)/functions.metadata"
DestinationFolder="$(DeployFullPath)/src/build/GeneXus.Deploy.AzureFunctions.Handlers" SkipUnchangedFiles="true" />

<Exec Command="dotnet sln $(DeploymentUnit).sln add &quot;$(DeploySrcBuildPath)/GeneXus.Deploy.AzureFunctions.Handlers/GeneXus.Deploy.AzureFunctions.Handlers.csproj&quot;" WorkingDirectory="$(DeploySrcBuildPath)" />

<!--Add dependencies to project-->
<Copy SourceFiles = "$(GX_PROGRAM_DIR)\DeploymentTargets\AzureFunctions\http\Directory.Build.targets"
DestinationFolder= "$(DeployFullPath)/src/build"/>

<Exec Command="dotnet build &quot;$(DeployFullPath)/src/build/$(DeploymentUnit).sln&quot; -c Release --force -p:DebugType=None -p:CosmosDBSupport=$(CosmosDBSupport) -p:TimerSupport=$(TimerSupport) -p:AzureQueueSupport=$(AzureQueueSupport) -p:ServiceBusSupport=$(ServiceBusSupport) -p:HttpSupport=$(HttpSupport) -p:BlobSupport=$(BlobSupport) -p:EventGridSupport=$(EventGridSupport)" WorkingDirectory="$(DeploySrcBuildPath)" ConsoleToMSBuild="true"/>

<Delete Files="$(DeployFullPath)/bin/local.settings.json" Condition="Exists('$(DeployFullPath)/bin/local.settings.json')" />

</Target>


<Target Name="GenerateSources" Condition = "'$(NETGenerator)' == 'true'">

<MakeDir
Expand Down Expand Up @@ -124,8 +166,9 @@
/>
</Target>

<Target Name="PrepareDeploy" DependsOnTargets="GenerateSources;GenerateConfigs;RedisSupport;CopyAzureBinaries;UpdateHostJsonFile" Condition="'$(NETGenerator)' == 'true'">
<Message Text="Adding required files to the deploy...(this may take a while)" Importance="high"/>
<Target Name="PrepareDeploy" DependsOnTargets="GenerateSources;GenerateConfigs;RedisSupport;AddAzureHandlersSources;BuildAzureHandlersSources;BuildAzureHandlersSourcesHTTP;UpdateHostJsonFile" Condition="'$(NETGenerator)' == 'true'">

<Message Text="Adding required files to the deploy...(this may take a while)" Importance="high"/>

<ItemGroup>
<ConfResources Include="$(DeployFullPath)\*.svc" />
Expand Down
Loading