The 'DefaultConnection-Web.config Connection String' argument cannot be null or empty. VS2013

后端 未结 4 1951
伪装坚强ぢ
伪装坚强ぢ 2020-12-28 13:01

When I deploy my project with \"Publish as Azure WebJob\" using Visual Studio 2013/update 4, I get the error in the title.

相关标签:
4条回答
  • 2020-12-28 13:17

    Reason of the problem
    Change and/or add the name of the connection string in 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 window. (No need to Restart Visual Studio)
    2. Try to publish the website again, and it should publish without a problem.

    NOTE
    I am using VS 2017 (and according to the comments this work also 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.

    0 讨论(0)
  • 2020-12-28 13:21

    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.

    0 讨论(0)
  • 2020-12-28 13:23

    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.

    0 讨论(0)
  • 2020-12-28 13:30

    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>
    
    0 讨论(0)
提交回复
热议问题