When I deploy my project with "Publish as Azure WebJob" using Visual Studio, I get the error in the title.
4 Answers
Fixed by removing the following markup from the .pubxml file. You must exit/restart VS after removing the markup (or VS will add it back in).
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)DefaultConnection-Web.config Connection String" />
</ItemGroup>

- 16,800
- 14
- 110
- 131

- 20,912
- 8
- 60
- 78
-
1does this change depending on the name of your connection string in App.Config? – James Reategui Mar 27 '15 at 13:13
-
These were readded for me after restarting. This worked in my case: http://stackoverflow.com/questions/28391460/how-do-i-setup-connection-strings-for-a-webjob-project – Noah Stahl May 01 '15 at 16:10
-
1Thanks for the answer. Made me realize I should just delete the publishing profile and create a new one. – hvaughan3 Jan 18 '16 at 23:17
-
1Using VS2015, update 2. It was the "restart Visual Studio" part that I was missing. THANK YOU. Now on to the next issue... – CindyH Aug 02 '16 at 19:46
-
1This doesn't work in Update 3 in VS 2015, please see my answer above by changing an attribute in pubxml file. – Mostafa Nov 24 '16 at 02:36
-
This worked for me in VS2017. I also deleted everything inside the `
` tags. We're using the Azure Application Settings for connection strings and don't need MSDeploy updating the config file. Be careful if you use VS UI to configure the publish profile again as it will add the connection string info back and you'll need to manually remove it again. – John Mills Jun 08 '18 at 02:49
Reason of the problem is one of the followings:
- Change the name of the connection string in the
web.config
. - Add a new connection string in the
web.config
Solution
- Select the website project, right-click on it, and click publish.
Press the settings link and from the pop-up window select the 'Settings' Tab
Uncheck the
use this connection string at runtime
from all your connection strings.
- Click the
Save
button to close the window. (No need to restart Visual Studio) - Try to publish the website again, and it should publish without a problem.
- You can reconfigure the settings as it was previously, the unchecking just triggers VS to regenerate the .pubxml file, So you are not forced to change your settings at all.
NOTE
I am using VS 2017 (and according to the comments this also work in Visual Studio 2013)
Just for Note
After I did the previous steps, I noticed that the .pubxml file changed automatically. here is the difference which has been made (automatically without any interference from me)
So I think this is a better way because it is easier for the developer and also it let the visual studio to solve its problems himself, without forcing it into a specific thing.

- 16,800
- 14
- 110
- 131
-
1This works for me. VS2013. Just uncheck the Use Connection String at Runtime box in the Publish dialog. – JohnWrensby Apr 12 '18 at 15:04
-
2When I untick that option and press 'save', visual studio ignores it. When I open the settings again - the option is still checked. I can't get it to respect my preference. I can't have it run migrations without it injecting the connection string. Therefore I have to have one publish profile with the connection string to run migrations (injects into web.config), then a second with no connection string (no migrations) which then clears the web.config of any connection strings. Seems like a bug in VS2017:15.6.7?? or maybe AzureAppSericeTools build 15.0.40215.0 - very annoying! – stuzor Dec 12 '18 at 10:45
-
1Followed the steps and then restarted Visual Studio. After restart error was gone – Jay Aug 13 '19 at 22:02
-
1This no longer works in VS 2019. The checkboxes are there but they're ignored and MS has closed bug tickets reporting this. – Josh Noe Feb 27 '20 at 18:53
-
@JoshNoe nice note, but this answer would still be helpful for people using VS 2017 and before. It would be helpful if you provide link to the bug, I will update my answer with according to your note. – Hakan Fıstık Feb 28 '20 at 06:00
-
Here's the link to one of the bug reports, which is actually for VS 2017: https://developercommunity.visualstudio.com/content/problem/308657/can-not-uncheck-use-this-connection-string-at-runt.html – Josh Noe Feb 28 '20 at 22:36
Create a Parameters.xml file in the Project root with the following content:
<?xml version="1.0" encoding="utf-8" ?>
<parameters>
<parameter name="DefaultConnection-Web.config Connection String"
description="DefaultConnection"
defaultValue="Server=tcp:x.database.windows.net,1433;Database=x_db;User ID=x@y;Password=z;Trusted_Connection=False;etc." tags="" />
</parameters>
All the other missing config elements can be added here as well.

- 111
- 6
-
this worked for me, although it didn't actually set the connection string as i had hoped. – James Reategui Mar 28 '15 at 02:37
-
I guess it will come from the App.config, it is just a must have to workaround the issue. – Norbert Kardos Jul 31 '15 at 14:17
-
2Black magic! So Deploy as WebJob just reads from any XML file in the Project root? – phillipwei Nov 11 '15 at 00:20
-
-
This works, but I don't like it. My first deploy worked perfectly only my second deploy complained about missing connection strings. – connectedsoftware Mar 07 '17 at 14:59
I have Visual Studio 2015 Update 3 and i was facing the same issue. The solution i found that is working for me is the following:
1) Open *.pubxml file under properties -> publish profiles.
2) Look for the Path attribute under PublishDatabaseSettings section:
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="eRecall.ETL.Models.erecallContext" Order="1" Enabled="False">
<Destination Path="" />
<Object Type="DbCodeFirst">
<Source Path="DBContext" DbContext="eRecall.ETL.Models.erecallContext, eRecall.ETL" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
3) Set Path attribute value to the following:
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="eRecall.ETL.Models.erecallContext" Order="1" Enabled="False">
<Destination Path="{deployment connection string}" />
<Object Type="DbCodeFirst">
<Source Path="DBContext" DbContext="eRecall.ETL.Models.erecallContext, eRecall.ETL" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
4) Delete the existing webjob deployment in Azure Job Collection Scheduler.
5) Re-Deploy the webjob, Re-run the webjob from the scheduler and it starts working with no issues!
Hope this helps.

- 3,296
- 2
- 26
- 43