Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.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)

like image 267
PabloPaezSheridan Avatar asked Oct 28 '25 10:10

PabloPaezSheridan


2 Answers

I found a similar issue in which the azure function is unable to generate the bin folder.

To resolve this issue, use the workaround given by @BabyGiant.

Add the below configuration in the build.targets:

 <Target Name="MakeMyDir" AfterTargets="Build">
    <MakeDir Directories="$(PublishDir)bin" />
  </Target>

the azure function where not listing the azure functions in the resource in azure portal

This happens due to various reasons. As you have migrated the function from .NET core 3.1 to .NET 6.0, the issue could be due to missing configurations or version incompatibility between the packages.

Create a sample .NET 6.0 Azure function and compare the folder structure, files, configurations and the package versions with your existing function project as @Miao Tian-MSFT mentioned in the comments.

local.settings.json:

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
  }
}

host.json:

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true,
                "excludedTypes": "Request"
            },
            "enableLiveMetricsFilters": true
        }
    }
}

.csproj:

Check the package versions.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.4.0" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

Create a publish profile with Release configuration and Deploy the function to Azure:

enter image description here

like image 132
Pravallika KV Avatar answered Oct 31 '25 09:10

Pravallika KV


I have an isolated function so I have a configured a dotnet-isolated FUNCTIONS_WORKER_RUNTIME.

According to your comment, I created two Azure Functions applications to test the issue.

One is using .NET 6 runtime. When published to folder in local visual studio, it publishes with a bin folder. .NET 6 runtime

Another is using .NET 6 Isolated runtime. When published to folder in local visual studio, it publishes no bin folder. .NET 6 Isolated runtime

After checking the official documentation, I found that this is by design.

Sample content files for Azure Functions in the in-process model (.NET 6) in the official documentation:

<framework.version>
 | - bin
 | - MyFirstFunction
 | | - function.json
 | - MySecondFunction
 | | - function.json
 | - host.json

Sample content files for Azure Functions in the isolated worker model (.NET 6 Isolated ) in the official documentation:

  • .azurefunctions/
  • extensions.json
  • functions.metadata
  • host.json
  • worker.config.json
  • Your project executable (a console app)
  • Other supporting files and directories peer to that executable

So, as you are using the .NET 6 Isolated runtime for your azure function project, you should not look for the bin folder. Maybe you can consider using the .NET 6 runtime instead of .NET 6 Isolated runtime to get a bin folder.

like image 27
Miao Tian Avatar answered Oct 31 '25 08:10

Miao Tian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!