Search code examples
.netazure-devopsazure-functionsazure-functions-isolatedvisual-studio-publish

.Net Azure Function app publish does not generate a bin folder


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

Azure function project file(first lines)

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

artifact folder after publish (without bin folder)


Solution

  • 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:

    • X.Functions.exe
    • X.Functions.runtimeconfig.json

    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