Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure WebJobs ServiceBus returns Exception: found 2 DNS claims in authorization context

I'm trying to read a message from an Azure ServiceBus queue using an Azure WebJob but it's throwing and exception:

Unhandled Exception: System.InvalidOperationException: Found 2 DNS claims in authorization context.

I've set the correct connection strings named "AzureWebJobsServiceBus", "AzureWebJobsDashboard" and "AzureWebJobsStorage"

The WebJob Program code has been updated to use JobHostConfiguration:

class Program
{
    static void Main()
    {
        var config = new JobHostConfiguration();
        config.UseServiceBus();

        var host = new JobHost(config);
        host.RunAndBlock();
    }
}

And the actual Job method

public class Functions
{
    public async static Task ServiceBusResizeRequest(
         [ServiceBusTrigger("blah")] string message,             
         TextWriter log
         )
    {            
        await log.WriteLineAsync("got message " + message);
    }

}

I can successfully create and write to the queue via a separate console application.

But when I run the webjob application, it throws that exception.

Any ideas?

EDIT: Using .net 4.6.1

like image 764
sf. Avatar asked Dec 17 '15 07:12

sf.


3 Answers

The answer marked as solution, is not the solution, it is a botched job. The solution to use it in .Net Framework 4.6.1 is to add in the rutime block in App.config:

<AppContextSwitchOverrides value="Switch.System.IdentityModel.DisableMultipleDNSEntriesInSANCertificate=true" />

Read this article Mitigation: X509CertificiateClaimSet.FindClaims Method

Very IMPORTANT for now Azure WebApps / WebJob etc, doesn't support 4.6.1 I will note here when (said at jan 21, 2016).

It means, that you can develop a web job application with 4.6.1, but when you push it to Azure, you can see exceptions like Job failed due to exit code -2146232576

like image 136
Alberto León Avatar answered Oct 01 '22 10:10

Alberto León


January 29th Microsoft released version 3.1.3 of the NuGet package WindowsAzure.ServiceBus.

From the release notes:

• General: .Net 4.6.1+ compatibility fix. Fixing custom DNS IdentityVerifier so that we honor multiple DNS claims returned by WIF

Upgrading the package solved the problem for us.

like image 21
lsmeby Avatar answered Oct 01 '22 12:10

lsmeby


As outlined in this answer above, the snippet below does the trick

<runtime>
    ...
    <AppContextSwitchOverrides value="Switch.System.DisableMultipleDNSEntriesInSANCertificate=true" />
    ...
<runtime>

BUT be carefull to add it to the correct project in your solution! Add it to the project containing the Azure code and Azure references.

like image 3
participant Avatar answered Oct 01 '22 12:10

participant