Azure Functions Service Bus trigger not working with Docker

Ryan Shirley 0 Reputation points
2023-10-23T18:50:34.55+00:00

I am facing issues when I include a service bus trigger in my Azure function using Docker. For background I have an Azure function .NET 6 V4 running dotnet-isolated version that I have packaged up with Docker. My http endpoint is working as expected however, when I include my service bus trigger the startup fails when running inside docker. This results in the HTTP endpoint no longer working also. When running locally without docker I have no issues with triggering the HTTP endpoint or service bus trigger.

System.TypeLoadException: Could not load type 'Microsoft.Azure.WebJobs.ParameterBindingData' from assembly 'Microsoft.Azure.WebJobs'

Dockerfile

FROM mcr.microsoft.com/dotnet/sdk:6.0
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4.0-dotnet-isolated6.0
<ItemGroup>  
	<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />  			   	
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.14.0" />  
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.15.1" />
</ItemGroup>

Service bus trigger

[Function(nameof(ServiceBusReceivedMessageFunction))]
public string ServiceBusReceivedMessageFunction(
[ServiceBusTrigger("queue-name", Connection = "ServiceBusConnection")] ServiceBusReceivedMessage message)
{    
	_logger.LogInformation("Message ID: {id}", message.MessageId);    
	_logger.LogInformation("Message Body: {body}", message.Body);    
	_logger.LogInformation("Message Content-Type: {contentType}", message.ContentType);    
	var outputMessage = $"Output message created at {DateTime.Now}";    
	return outputMessage;
}

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,908 questions
Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
685 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 29,261 Reputation points
    2023-10-25T05:13:16.02+00:00

    @Ryan Shirley Thanks for sharing the solution in the thread so that it will benefit others experiencing the similar issue. Since the Microsoft Q&A community has a policy that The question author cannot accept their own answer. They can only accept answers by others, I will repost your solution in case you like to accept the answer for greater visibility.

    Issue: facing issues when you include a service bus trigger in Azure function using Docker.

    Solution: Changing the SDK from FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4.0-dotnet-isolated6.0 to FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4.27.5-dotnet-isolated6.0 has fixed the issue

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.