How do I setup Connection Strings for a WebJob project?

前端 未结 3 1528
忘了有多久
忘了有多久 2021-02-02 09:43

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

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-02 09:48

    Reason of the problem
    Change the name of the connection string in the Web.Config or/and adding a new connection string to the Web.Config.

    Solution

    1. Select the website project, right click on it, and click publish.

    1. Press the settings link and from the pop-up window select the 'Settings' Tab

    2. Uncheck the use this connection string at runtime from all your connection strings.

    1. Click Save button to close the the window. (No need to Restart Visual Studio)
    2. Try to publish the website again, and it should publish without problem.

    NOTE
    I am using VS 2017

    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 better way because it is easier for developer and also it let the visual studio to solve its problems himself, without forcing it for specific thing.

提交回复
热议问题