Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure WebJob Storage Connection

I have these connection strings in my App.config for an Azure WebJob

<add name="AzureWebJobsDashboard" connectionString="UseDevelopmentStorage=true"/>
<add name="AzureWebJobsStorage" connectionString="UseDevelopmentStorage=true"/>

because I want it to default to Azure Storage Emulator for developers. However, when these WebJobs are used on Azure, they seem to still point to local storage, despite the fact that I've set these connection strings in the Azure Portal interface:

Azure Portal Application Settings Connection Strings

I'm inferring it is still pointing to local storage because I get this error:

Microsoft.WindowsAzure.Storage.StorageException: Unable to connect to the remote server ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:10001 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)

in our logging right at the first point we try to connect to Azure Storage.

Am I missing something? Have I set up the connection strings properly for WebJobs? How can I set them up to default to local storage for developers but have a real connection string for the app running in Azure?

like image 314
Scotty H Avatar asked Oct 18 '22 10:10

Scotty H


1 Answers

Firstly, I am sure that configurations in Azure portal have higher priority than configurations in web.config/app.config.

According to image you uploaded, I saw that you chosen Event Hub and SQL Database types for your Azure Storage connection strings. It will have some issues if you choose Event Hub type for Azure Storage connection string, please change the connection type to Custom to fix this issue.

enter image description here

You could print out the connection strings in your WebJob to confirm it.

var host = new JobHost(config);

Console.WriteLine(config.DashboardConnectionString);
Console.WriteLine(config.StorageConnectionString);
like image 149
Amor Avatar answered Oct 29 '22 23:10

Amor