Skip to content

Azure function app can't load kafka dll #621

Open
@IvanovOleg

Description

@IvanovOleg

Description

I am trying to create a kafka producer using Azure functions and getting this error:

Inner exception System.DllNotFoundException handled at System.RuntimeMethodHandle.InvokeMethod: at Confluent.Kafka.Impl.LibRdKafka.Initialize (Confluent.Kafka, Version=0.11.5.0, Culture=neutral, PublicKeyToken=null) at Confluent.Kafka.Producer..ctor (Confluent.Kafka, Version=0.11.5.0, Culture=neutral, PublicKeyToken=null) at Confluent.Kafka.Producer`2..ctor (Confluent.Kafka, Version=0.11.5.0, Culture=neutral, PublicKeyToken=null) at Submission#0.Run (f-TimerTriggerCSharp1__929840893, Version=0.0.0.0, Culture=neutral, PublicKeyToken=nullf-TimerTriggerCSharp1__929840893, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null: D:\home\site\wwwroot\TimerTriggerCSharp1\run.csxf-TimerTriggerCSharp1__929840893, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null: 20)

How to reproduce

run.csx

using System;
using System.IO;
using System.Text;
using Confluent.Kafka;
using Confluent.Kafka.Serialization;

public static void Run(TimerInfo myTimer, ILogger log)
{
    log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
    var config = new Dictionary<string, object>
    {
        { "bootstrap.servers", "localhost:9094" },
        { "security.protocol", "sasl_ssl"},
        { "ssl.ca.location", Path.Combine(Directory.GetCurrentDirectory(), "ca.pem")},
        { "sasl.mechanism", "PLAIN"},
        { "sasl.username", "admin"},
        { "sasl.password", "admin"},
        { "debug", "all"}
    };
    using (var producer = new Producer<Null, string>(config, null, new StringSerializer(Encoding.UTF8)))
    {
        var dr = producer.ProduceAsync("test", null, "myEventHubMessage").Result;
    }
}

function.proj

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
 
  <ItemGroup>
    <PackageReference Include="Confluent.Kafka" Version="0.11.5"/>
    <PackageReference Include="librdkafka.redist" Version="0.11.5"/>
  </ItemGroup>
 
</Project>

I've tested this code (with a little changes) in the Visual Studio 2017 and it works.

Checklist

Please provide the following information:

  • Confluent.Kafka nuget version: 0.11.5
  • Apache Kafka version: 2.0.0
  • Client configuration: Azure Function App v2
  • Operating system: Windows
  • Provide logs (with "debug" : "..." as necessary in configuration)
  • Provide broker log excerpts
  • Critical issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    MEDIUMinvestigate furtherwe want to further investigate to understand properly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions