3

I'm adding a new azure function (isolated process) to a running .net 7 project, but got the compile error "The attribute 'ServiceBusTrigger' is a WebJobs attribute and not supported in the .NET Worker (isolated process)".

We're using isolated process for .net 7 at the moment and it can't be changed.

Even the simple function generated by chatGPT also can't be built because of that error

[Function("MyServiceBusTriggerFunction")] public static void Run( [ServiceBusTrigger("", "")] ServiceBusReceivedMessage message, FunctionContext context) { }

Any help will be much appreciated.

5
  • Does this answer your question? Azure function worker isolated process .NET 6 - work with servicebus and servicebus trigger Commented Jul 18, 2023 at 9:18
  • 1
    please check if you have below packages in your .csproj file <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.10.0" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="4.2.1" /> <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" /> Commented Jul 18, 2023 at 11:17
  • Would this solution work with .NET 7? Commented Jul 18, 2023 at 11:21
  • Yes, It worked for me and even I am using .NET 7 isolated process Commented Jul 18, 2023 at 11:27
  • It works, thank you Ikhtesam Afrin @IkhtesamAfrin Commented Jul 19, 2023 at 7:44

1 Answer 1

4

I have reproduced the issue at my environment using .Net 7 isolated process with service Bus triggered function and got the expected result

The attribute 'ServiceBusTrigger' is a WebJobs attribute and not supported in the .NET Worker (isolated process)

Please check if you have below items in your .csproj file. You can refer to this SO Thread for more details about the error.

<ItemGroup>

<PackageReference  Include="Microsoft.Azure.Functions.Worker"  Version="1.10.0"  />
<PackageReference  Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus"  Version="4.2.1"  />
<PackageReference  Include="Microsoft.Azure.Functions.Worker.Sdk"  Version="1.7.0"  />

</ItemGroup>

I have created a default service Bus queue triggered function using VS code.

I have below files created in vs code

enter image description here

Code:

using  System;
using  Microsoft.Azure.Functions.Worker;
using  Microsoft.Extensions.Logging;

namespace  Company.Function
{

public  class  ServiceBusQueueTrigger1
{
private  readonly  ILogger  _logger;
public  ServiceBusQueueTrigger1(ILoggerFactory  loggerFactory)
{
_logger  =  loggerFactory.CreateLogger<ServiceBusQueueTrigger1>();
}
[Function("ServiceBusQueueTrigger1")]
public  void  Run([ServiceBusTrigger("myqueue", Connection  =  "afreen001_SERVICEBUS")] string  myQueueItem)
{
_logger.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
}
}

local.settings.json:

{

"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"afreen001_SERVICEBUS": "*****************"

}
}

Output:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.