Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I setup Connection Strings for a WebJob project?

I am trying to setup a website and webjob, but get an error everytime I try to publish the webjob independently of the website (i.e. Selecting Publish as Azure WebJob from the context menu)

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4270,5): Error : The 'MyWebJob.Models.MyDataEntities-Web.config Connection String' argument cannot be null or empty.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(4270,5): Error : The 'MyWebJob.Models.MoreDataEntities-Web.config Connection String' argument cannot be null or empty.

There are two options for deploying a WebJob

  • Deploy with a website project
  • Deploy the webjob independently

When I link my webjob to a website project, it deploys with the website without error. However, when I try to deploy it independently I get the above error in my console and Error List, but the webjob is still deployed.

How can I deploy my webjob independently and get rid of this persistent "error"?

like image 912
Enrico Avatar asked Feb 08 '15 07:02

Enrico


People also ask

How do I run a WebJob in Visual Studio?

In Visual Studio, select File > New > Project. Under Create a new project, select Console Application (C#), and then select Next. Under Configure your new project, name the project WebJobsSDKSample, and then select Next. Choose your Target framework and select Create.


1 Answers

I found that providing a value for

 <Destination Path="" />  

in your publish profile pubxml file got rid of the issue. This can usually be found in \Properties\PublishProfiles. You probably have something like:

<PublishDatabaseSettings>   <Objects xmlns="">     <ObjectGroup Name="Context" Order="1" Enabled="False">       <Destination Path="" />       <Object Type="DbCodeFirst">         <Source Path="DBMigration" DbContext="Context, DAO" MigrationConfiguration="Context.Migrations.Configuration, DAO" Origin="Convention" />       </Object>     </ObjectGroup>   </Objects> </PublishDatabaseSettings> 

Changing it to the following fixed it for me:

<PublishDatabaseSettings>   <Objects xmlns="">     <ObjectGroup Name="Context" Order="1" Enabled="False">       <Destination Path="{deployment connection string}" />       <Object Type="DbCodeFirst">         <Source Path="DBMigration" DbContext="Context, DAO" MigrationConfiguration="Context.Migrations.Configuration, DAO" Origin="Convention" />       </Object>     </ObjectGroup>   </Objects> </PublishDatabaseSettings> 

Hope that helps.

like image 152
Willisterman Avatar answered Sep 20 '22 19:09

Willisterman