I work a lot to migrate an azure function app from net core 3.1 to net 6. After a long time i made all the azure functions to work fine in local. The next step was to deploy the azure function. The build and publish run successfully in the pipeline but, even when the runtimes changes impacted, the azure function where not listing the azure functions in the resource in azure portal.
There were something wrong with the artifact the we were trying to publish
We make a lot of research and we realize that the bin folder was not present in the artifact generated after publish the azure function. This happens in local too with local publish from visual studio. We have another net 6 azure function that, after publish, the bin folder is present with all the dll so we are sure that is not something related to net 6
After a lot of research we deploy the azure app in a test resource group in azure using visual studio directly. The deploy was successful and the function app works. We confirm that the bin folder was not needed because of, using Kudo, the files deployed does not have the bin folder.
However there were some inconsistencies between the files deployed from visual studio using the test resource group and the real ones. There were two missing files:
After a lot of differents test i realize that maybe i could use the Publish Profile that Visual Studio autogenerates using my configurations to do the publish before deployed the files in the resource. There is a way to use a publish with profile extension file using the dotnet publish command so we could include that in our pipeline.
The publish profile was named CloudPublishProfile.pubxml and the content is the next one:
<Project>
<PropertyGroup>
<WebPublishMethod>ZipDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<LaunchSiteAfterPublish>false</LaunchSiteAfterPublish>
<UpdateApiOnPublish>true</UpdateApiOnPublish>
</PropertyGroup>
</Project>
The dotnet publish command task ends like this where :
- task: DotNetCoreCLI@2
displayName: "Copy AzureFunctions build output"
enabled: true
inputs:
arguments: '--configuration Release -p:PublishProfile=CloudPublishProfile --no-build --no-self-contained --output "$(Build.ArtifactStagingDirectory)/legacy/X.Azure.Functions"'
command: "publish"
publishWebProjects: false
workingDirectory: "$(Build.SourcesDirectory)/legacy/X.Azure.Functions/"
zipAfterPublish: true
After that the deployed files between the app deployed in the test resource (the one is working) and the real one have no differences between them. They have the exactly the same quantity and structure of files. There where only one difference remaining. The test azure function apps works and the other not :(
I post this as an answer because of the question itself is answered but the original problems remains.When eventually we manage to solve this i will came back to this question and i will post the update. Until that stay safe and thank you very much
25/10/2024 Update
We finally manage to deploy the azure function!
The Microsoft team contact us after we create a request to them. They contact us thorugh a couple of engineers it turned out to be a general bug that was happening in a couple of .Net azure function process at that moment. After some day they come up to a solution:
From what I understand when reviewing this case is that after upgrading to .NET isolated 6 the function app’s functions are not visible in the portal.
The function app “X” seems to be currently experiencing the issue. When looking at this function app’s host.json from my tools I see the following which appears to have the extension bundle object:
{
"version": "2.0",
"logging": {
"fileLoggingMode": "always",
"logLevel": {
"default": "Information",
"Host.Results": "Information",
"Function": "Information",
"Host.Aggregator": "Trace"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensions": {
"http": {
"routePrefix": "api",
"hsts": {
"isEnabled": true,
"includeSubDomains": true,
"maxAge": "365"
}
}
},
extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
I have seen a similar issue before with a similar scenario with a .NET isolated function app not displaying the app’s functions. After removing the extensionBundle object from the function app’s host.json the issue was resolved since .NET isolated do not need an extension bundle. If possible can you please try removing the extensionBundle from the host.json file and redeploying? After you redeploy please let me know if the issue persists.
After we made this little change suggested in the host.json removing the extension bundle object and redeploy the problem was solved! All the functions where listed. It was very hard to us to discover the problem because the host.json was autogenerated by the migration tool from Microsoft that is provided in the Visual Studio Extensions. This tool made thousands of changes so was impossible to check them.