Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure: Web.config Connection String' argument cannot be null or empty

When I try to publish an azure app I get this error. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(4283,5): Error : The 'ibasis_Data_Transfer.mytestdbEntities-Web.config Connection String' argument cannot be null or empty.

My App.Config has a connection string. e.g.

 <add name="mytestdbEntities" connectionString="metadata=res://*/mytestappModel.csdl|res://*/mytestappModel.ssdl|res://*/mytestappModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=tcp:srv-mytestapp-home.database.windows.net,1433;initial catalog=mytestdb;persist security info=True;user id=blabla;password=blabla;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

Don't know where to start looking for solution as error not mentioned on web anywhere in relation to azure.

ibasis - Web Deploy.pubxml

<?xml version="1.0" encoding="utf-8" ?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <PublishProvider>AzureWebSite</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>http://ibasis.azurewebsites.net</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
    <MSDeployServiceURL>ibasis.scm.azurewebsites.net:443</MSDeployServiceURL>
    <DeployIisAppPath>ibasis</DeployIisAppPath>
    <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <UserName>$ibasis</UserName>
    <_SavePWD>True</_SavePWD>
    <_DestinationType>AzureWebSite</_DestinationType>
    <PublishDatabaseSettings>
      <Objects xmlns="">
        <ObjectGroup Name="ibasis_Data_Transfer.ibasisLiveEntities" Order="1" Enabled="False">
          <Destination Path="" />
          <Object Type="DbCodeFirst">
            <Source Path="DBContext" DbContext="ibasis_Data_Transfer.ibasisLiveEntities, ibasis-Data-Transfer" />
          </Object>
        </ObjectGroup>
      </Objects>
    </PublishDatabaseSettings>
  </PropertyGroup>
  <ItemGroup>
    <MSDeployParameterValue Include="$(DeployParameterPrefix)ibasis_Data_Transfer.ibasisLiveEntities-Web.config Connection String" />
  </ItemGroup>
  <ItemGroup>
    <_ConnectionStringsToInsert Include="ibasis_Data_Transfer.ibasisLiveEntities" />
  </ItemGroup>
</Project>

Update: As far as i can tell the VS publishing of simple Apps to Azure with 'database first' type entity(edmx) files is not possible.

The auto generated ....Web Deploy.pubxml gets filled with incompatible junk like and "DeployParameterPrefix" which can't be removed and break the build.

I only wanted to call simple Stored Procedure e.g.

 myappLiveEntities db = new myappLiveEntities();
 db.DoSomeDatabaseWork();

Will do it "old school" method.

like image 939
user964787 Avatar asked Mar 15 '16 00:03

user964787


2 Answers

I ran into this with a webjob I had been deploying successfully. I wound up deleting the pubxml file under the webjob project PublishProfiles folder and redoing the publish As Azure WebJob.

This issue popped up again when I upgraded to this specific nuget package: "Microsoft.WindowsAzure.ConfigurationManager" version="3.2.3" It may be an issue with publishing the webjob before publishing the updated web app or editing the WebApp publish settings ...

Edit: I've since switched to including the web job to the web app publish settings. You can do this by right clicking the project and choosing Add -> Existing Project as Azure Web Job. I no longer publish the WebJob separately.

like image 158
Art Metz Avatar answered Oct 18 '22 19:10

Art Metz


I believe you need to add a ParameterValue under the MSDeployParameterValue list item. For example,

<ItemGroup>
  <MSDeployParameterValue Include="Parameter Name">
    <ParameterValue>Parameter Value</ParameterValue>
  </MSDeployParameterValue>
</ItemGroup>
like image 25
chief7 Avatar answered Oct 18 '22 20:10

chief7