Philip Tenn
Philip Tenn

Reputation: 6073

Azure WebJobs Log Files/Key

I found the following post and followed the Accepted Answer, but I could not find the Connection String: Error in Azure WebJobs

I have a feeling the answer might be for the older Azure Portal, or for Cloud Apps, not the newer Web Apps.

I am doing an Azure Web App with WebJobs and I need to know how to enable logging. I get the error:

The configuration is not properly set for the Microsoft Azure WebJobs 
Dashboard. 

In your Microsoft Azure Website configuration you must set a connection 
string named AzureWebJobsDashboard by using the following format 
DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY pointing to 
the Microsoft Azure Storage account where the Microsoft Azure WebJobs 
Runtime logs are stored. 

I can't figure out how to get the AccountName/AccountKey.

Thank you very much,

Philip

Upvotes: 0

Views: 290

Answers (1)

Peter Bons
Peter Bons

Reputation: 29711

Did you already have or created a storage account that you can use? If not, you will need to do that first! It is a required manual step (or use an existing storage account of course). Then you can get the connection string. See the docs:

Create a connection string for an Azure storage account

To create a connection string for your Azure storage account, use the following format. Indicate whether you want to connect to the storage account through HTTPS (recommended) or HTTP, replace myAccountName with the name of your storage account, and replace myAccountKey with your account access key:

  • DefaultEndpointsProtocol=[http|https];AccountName=myAccountName;AccountKey=myAccountKey

For example, your connection string might look similar to:

DefaultEndpointsProtocol=https;AccountName=storagesample;AccountKey=

Tip

You can find your storage account's connection strings in the Azure portal. Navigate to SETTINGS > Access keys in your storage account's menu blade to see connection strings for both primary and secondary access keys.

Now, easiest way is to open the app.config file of your webjob project and add the connection string like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <connectionStrings>
    <!-- The format of the connection string is "DefaultEndpointsProtocol=https;AccountName=NAME;AccountKey=KEY" -->
    <!-- For local execution, the value can be set either in this config file or through environment variables -->
    <add name="AzureWebJobsDashboard" connectionString="DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx" />
    <add name="AzureWebJobsStorage" connectionString="DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx" />
  </connectionStrings>
  ...
</configuration>

Then deploy your web job.

Upvotes: 1

Related Questions