Skip to content

Commit

Permalink
Cherry pick branch 'genexuslabs:Issue201688' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabrina Juarez Garcia authored and Beta Bot committed Jan 28, 2025
1 parent cdea0ef commit c988eed
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 36 deletions.
45 changes: 39 additions & 6 deletions src/AzureServerless/createpackage.msbuild
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<Import Project="$(GX_PROGRAM_DIR)\GeneXus.AzureDeploy.targets"/>
<Import Project="$(GXDeployFileProject)"/>
<Import Project="$(GX_PROGRAM_DIR)\DeploymentTargets\AzureServerless\DeployStaticResources\deploystaticfiles.targets"/>
<Import Project="$(GX_PROGRAM_DIR)\DeploymentTargets\Common/Azure\azurefunctions-create-NETpackage.targets" Condition = "'$(GENERATOR)' == '.NET Core' or '$(GENERATOR)' == '.NET'"/>
<Import Project="$(GX_PROGRAM_DIR)\DeploymentTargets\Common/Azure\azurefunctions-create-Javapackage.targets" Condition = "'$(GENERATOR)' == 'Java'"/>


<PropertyGroup Condition="'$(GENERATOR)' == '.NET Core' or '$(GENERATOR)' == '.NET'">
<UploadSource>$(DeployFullPath)</UploadSource>
Expand All @@ -28,11 +31,7 @@
<Error Text = "Open API file was not generated successfully. Please check that you have executed a rebuild all having Generate OpenAPi interface property set to Yes." Condition = "!Exists($(OpenAPIDefinitionOutputFile))" />

<Message Text="Generating configuration file..." Importance="high"/>
<GenerateAzFunctionConfigsHttp

YamlFile = "$(OpenAPIDefinitionOutputFile)"
DeployFullPath="$(DeployAppDir)" />


<PropertyGroup>
<IntegratedSecurityEnabled Condition= "$(AZURE_SERVERLESS_GAM_CONNECTION_KEY) != ''">true</IntegratedSecurityEnabled>
<IntegratedSecurityEnabled Condition= "$(AZURE_SERVERLESS_GAM_CONNECTION_KEY) == ''">false</IntegratedSecurityEnabled>
Expand All @@ -55,7 +54,7 @@
<ConfigResources Include="$(DeployAppDir)\log.config" Condition="Exists('$(DeployAppDir)\log.config')"/>
<ConfigResources Include="$(DeployAppDir)\log.console.config" Condition="Exists('$(DeployAppDir)\log.console.config')"/>
<ConfigResources Include="$(DeployAppDir)\GeneXus.services" Condition ="Exists('$(DeployAppDir)\GeneXus.services')" />
<ConfigResources Include="$(DeployAppDir)\functions.metadata" />
<!--<ConfigResources Include="$(DeployAppDir)\functions.metadata" />-->
<ConfigResources Include="$(DeployAppDir)\azureflag.json" Condition ="Exists('$(DeployAppDir)\azureflag.json')" />
<ConfigResources Include="$(DeployAppDir)\appsettings.json" />
<ConfigResources Include="$(DeployAppDir)\CloudServices.config" Condition ="Exists('$(DeployAppDir)\CloudServices.config')" />
Expand Down Expand Up @@ -122,6 +121,40 @@
</Target>


<Target Name="SetupHttpFunctionsProject" Condition="'$(NETGenerator)' == 'true'" DependsOnTargets="TransformMVCToAzureFunctions" >

<Message Text="Adding Azure Functions Handlers sources to $(DeploymentUnit).sln" Importance="high" ></Message>

<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)" />

<CallTarget Targets="ProcessDeploySolution" />
</Target>

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

<Message Text="Converting controller-based web APIs to Azure functions..." Importance="high" />
<GenerateAzHTTPFunctionFromMVC
serviceSourcePath="$(DeploySrcWebPath)"/>
</Target>

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

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

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

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

</Target>

<Target Name="RedisSupport" Condition="'$(AZURE_SERVERLESS_SESSION_STATE_PROVIDER)' == 'Redis' AND '$(AZURE_SERVERLESS_SESSION_PROVIDER_ADDRESS)' != ''">

<Message Text="Enabling Redis support" Importance="high"/>
Expand Down
2 changes: 2 additions & 0 deletions src/Common/Azure/azurefunctions-create-Javapackage.targets
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
<!--Copy application JAR to lib directory if it's not WEB -->
<Copy SourceFiles="$(DeployFileFullPath)/$(ProjectName).jar" DestinationFolder="$(AzureTemporalDir)/lib" Condition ="'$(ApplicationType)' == 'Function' AND Exists('$(DeployFileFullPath)/$(ProjectName).jar')" />

<Error Text="Application JAR could not be found : $(DeployFileFullPath)/$(ProjectName).jar. Please check DeployFileFullPath and ProjectName properties." Condition="'$(ApplicationType)' == 'Function' AND !Exists('$(DeployFileFullPath)/$(ProjectName).jar')" />

<!--Copy Azure Functions handler to the root directory -->
<ItemGroup>
<HandlerJarFile Include="$(DeployFullPath)/gxazureserverless*.jar" />
Expand Down
67 changes: 37 additions & 30 deletions src/Common/Azure/azurefunctions-create-NETpackage.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<DeploySrcBuildPath>$(DeployFullPath)\src\build</DeploySrcBuildPath>
<DeploySrcWebPath>$(DeployFullPath)/src/web</DeploySrcWebPath>
<AzureFunctionsHandlerProject>GeneXus.Deploy.AzureFunctions.Handlers.csproj</AzureFunctionsHandlerProject>
<AzureFunctionsLibrariesProject>GeneXus.Deploy.AzureFunctionsLibraries.csproj</AzureFunctionsLibrariesProject>
</PropertyGroup>

<ItemGroup>
Expand All @@ -19,69 +20,75 @@

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

<Target Name="TransformMVCToAzureFunctions" Condition="'$(NETGenerator)' == 'true' AND '$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'http'">
<Target Name="RestControllersToAzureFunctions" Condition="'$(NETGenerator)' == 'true' AND '$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'http'">

<Message Text="Converting controller-based web APIs to Azure functions..." Importance="high" />
<GenerateAzHTTPFunctionFromMVC
serviceSourcePath="$(DeploySrcWebPath)"/>
</Target>

<Target Name="AddAzureHandlersSources" Condition="'$(DeployType)'=='SOURCES' AND '$(NETGenerator)' == 'true'" DependsOnTargets="TransformMVCToAzureFunctions">
<Target Name = "CopyAzureHandlersSrc" Condition="'$(NETGenerator)' == 'true'">

<Message Text="Adding Azure Functions Handlers sources to $(DeploymentUnit).sln" Importance="high" ></Message>

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

<Copy SourceFiles="$(DeployAppDir)/functions.metadata"
DestinationFolder="$(DeployFullPath)/src/build/GeneXus.Deploy.AzureFunctions.Handlers" SkipUnchangedFiles="true" Condition="Exists('$(DeployAppDir)/functions.metadata')"/>
DestinationFolder="$(DeploySrcBuildPath)/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="SetupHttpFunctionsProject" Condition="'$(NETGenerator)' == 'true' AND '$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'http'" DependsOnTargets="TransformMVCToAzureFunctions" >

<Message Text="Adding Azure Functions Handlers sources to $(DeploymentUnit).sln" Importance="high" ></Message>

<Target Name="AddAzureHandlersSources" Condition="'$(DeployType)'=='SOURCES' AND '$(NETGenerator)' == 'true'" DependsOnTargets="RestControllersToAzureFunctions">

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

<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/$(AzureFunctionsHandlerProject)&quot;" WorkingDirectory="$(DeploySrcBuildPath)" />
<!--ONLY HTTP-->
<Exec Command="dotnet sln $(DeploymentUnit).sln add &quot;$(DeploySrcBuildPath)/GeneXus.Deploy.AzureFunctionsLibraries/$(AzureFunctionsLibrariesProject)&quot;" WorkingDirectory="$(DeploySrcBuildPath)" />

</Target>

<Target Name="SetupHttpFunctionsProject" Condition="'$(NETGenerator)' == 'true' AND '$(AZURE_FUNCTIONS_TRIGGER_TYPE)' == 'http'" DependsOnTargets="RestControllersToAzureFunctions" >

<CallTarget Targets="CopyAzureHandlersSrc" />

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

<CallTarget Targets="ProcessDeploySolution" />
</Target>

<Target Name="ProcessDeploySolution">

<Message Text="Re-structuring the solution to implement Azure functions.." Importance="high" />

<SetupAzureFuncDeploymentSln
DeploySolutionPath = "$(DeploySrcBuildPath)">
<Output TaskParameter="AzureProjectFiles" ItemName="AzureProjectFiles" />
</SetupAzureFuncDeploymentSln>

<Exec Command="dotnet add &quot;%(AzureProjectFiles.Identity)&quot; reference &quot;$(DeploySrcBuildPath)/GeneXus.Deploy.AzureFunctionsLibraries/$(AzureFunctionsLibrariesProject)&quot;" WorkingDirectory="$(DeploySrcBuildPath)" ConsoleToMSBuild="true"/>

<Copy SourceFiles="$(GX_PROGRAM_DIR)\DeploymentTargets\Common\Azure\Templates\AzureFunctionsHTTP\directory.build.targets"
DestinationFolder="$(DeploySrcBuildPath)" SkipUnchangedFiles="true" Condition="Exists('$(GX_PROGRAM_DIR)\DeploymentTargets\Common\Azure\Templates\AzureFunctionsHTTP\directory.build.targets')"/>

</Target>

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

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

<Exec Command="dotnet build &quot;$(DeployFullPath)/src/build/$(DeploymentUnit).sln&quot; -c Release --force -p:DebugType=None --p:OutputPath=&quot;$(DeployFullPath)\bin&quot; -p:CosmosDBSupport=$(CosmosDBSupport) -p:TimerSupport=$(TimerSupport) -p:AzureQueueSupport=$(AzureQueueSupport) -p:ServiceBusSupport=$(ServiceBusSupport) -p:HttpSupport=$(HttpSupport) -p:BlobSupport=$(BlobSupport) -p:EventGridSupport=$(EventGridSupport) -p:WebBinDirectory=&quot;$(DeployFullPath)\bin&quot;" WorkingDirectory="$(DeploySrcBuildPath)" ConsoleToMSBuild="true"/>
<Message Text="Building the solution..." Importance="high" />

<Exec Command="dotnet build &quot;$(DeployFullPath)/src/build/$(DeploymentUnit).sln&quot; -c Release --force -p:DebugType=None --p:OutputPath=&quot;$(DeployFullPath)\bin&quot; -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="ProcessDeploySolution">

<Message Text="Re-structuring the solution to implement Azure functions.." Importance="high" />

<SetupAzureFuncDeploymentSln
DeploySolutionPath = "$(DeploySrcBuildPath)"
DeploySrcWebDirectory = "$(DeploySrcWebPath)">
<Output TaskParameter="ProjectFiles" ItemName="ProjectFiles" />
</SetupAzureFuncDeploymentSln>

<Exec Command="dotnet add &quot;$(DeploySrcBuildPath)/GeneXus.Deploy.AzureFunctions.Handlers/GeneXus.Deploy.AzureFunctions.Handlers.csproj&quot; reference &quot;$(DeploySrcBuildPath)/GeneXus.Programs.Common/GeneXus.Programs.Common.csproj&quot;" WorkingDirectory="$(DeploySrcBuildPath)" ConsoleToMSBuild="true"/>

<Exec Command="dotnet sln $(DeploymentUnit).sln remove %(ProjectFiles.Identity)" WorkingDirectory="$(DeploySrcBuildPath)" ConsoleToMSBuild="true"/>

</Target>

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

<PropertyGroup>
Expand Down

0 comments on commit c988eed

Please sign in to comment.