Azure WebJobs SDK ServiceBus AzureWebJobsAzureSBConnection connection string missing or empty

I created the Azure Function application in Visual Studio 2015. The application has a trigger for service bus queues. The application works fine when I run it locally. It can read data from the service bus queue (configured using the AzureSBConnection variable) and register it in my database.

But this brings me the following error when deploying to Azure:

Function ($ ServiceBusQueueTriggerFunction) Error: Microsoft.Azure.WebJobs.Host: Error Indexing Method 'Functions.ServiceBusQueueTriggerFunction'. Microsoft.Azure.WebJobs.ServiceBus: Microsoft Azure WebJobs SDK ServiceBus connection string "AzureWebJobsAzureSBConnection" is missing or empty.

Please note that my connection is called AzureSBConnection, not AzureWebJobsAzureSBConnection. In addition, the connection works locally. And finally, the deployed file looks exactly like a local file.

The structure of Visual Studio is as follows:

Visual Studio Structure

The function.json file has many settings, as shown below:

Function.json

Then in the Appsettings.json file I have the following:

Application settings

For deployment, I transferred the FTP files to the folder D: \ home \ site \ wwwroot for my app-application in Azure. The final structure in Kudu looks like this:

wwwroot

And if I go into my function folder:

enter image description here

Here is the expanded .json function:

Deployed Function.json

And here are the detailed appsettings settings:

Detailed application settings

The deployed json files are exactly the same as the local ones. But the deployed version is an error due to the lack of AzureWebJobsAzureSBConnection. What am I doing wrong?

+5
source share
2 answers

Only environment variables for application settings and connection strings are supported.

You need to make sure that the environment variable AzureWebJobsAzureSBConnection set in the settings of your application-application in the portal:

function app

and then after that you need to add the AzureWebJobsAzureSBConnection variable with the corresponding connection string:

enter image description here

and then you can access this through code:

 Environment.GetEnvironmentVariable(name, EnvironmentVariableTarget.Process); 

This will get the value from the appsettings.json variable or environment depending on where the function is running (local debugging or deployment on Azure)

+8
source

It is able to read data from the service bus queue (configured using the AzureSBConnection variable). But when deployed to Azure, it raises the following error:

After you deploy your application to Azure Function, your application will read the connection string from your environment settings. Currently, the connection settings in appsettings.json will not automatically update the environment settings. We could click the [Configure Application Settings] button as indicated by @flyte to check if the connection string has been configured successfully. If not, you can add it manually in the application settings field.

Please note that my connection is called AzureSBConnection, not AzureWebJobsAzureSBConnection

Go to the [Integration] page to check if the [service bus] connection is successful. If not, you can reset it by clicking the link.

enter image description here

+1
source

Source: https://habr.com/ru/post/1265848/


All Articles