Azure-functions-host: "Microsoft.Data.SqlClient is not supported on this platform" despite function.deps.json

Created on 27 Dec 2019  路  13Comments  路  Source: Azure/azure-functions-host

I seem to have hit a similar issue to Azure/Azure-Functions#1370 using EF Core, VS 16.4.2, and functions runtime 3.0.12930.0 - I get "Microsoft.Data.SqlClient is not supported on this platform" with or without FUNCTIONS_V2_COMPATIBILITY_MODE. I'm referencing Microsoft.Data.SqlClient 1.1.0 everywhere I can find it and the functions.deps.json and runtimes folder are present in bin.

I noticed that the file size on the Microsoft.Data.SqlClient in the bin folder is different to the filesize in my .nuget and the runtimes version (339KB in bin vs 1241KB in .nuget, despite same versions in properties).

Inspired by https://stackoverflow.com/a/53952815/908 I included this in .csproj:

  <!-- For publish -->
  <ItemGroup>
    <None Include="$(USERPROFILE)\.nuget\packages\microsoft.data.sqlclient\1.1.0\runtimes\win\lib\netcoreapp2.1\Microsoft.Data.SqlClient.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>
  <!-- For local debug -->
  <Target Name="CopyToBin" BeforeTargets="Build">
    <Copy SourceFiles="$(USERPROFILE)\.nuget\packages\microsoft.data.sqlclient\1.1.0\runtimes\win\lib\netcoreapp2.1\Microsoft.Data.SqlClient.dll" DestinationFolder="$(OutputPath)\bin" />
  </Target>

This copies the .nuget version into bin and it seems to work fine.

Any ideas what's going on here? I've tried a minimal functions app using EF and that seems to work fine (with the 339KB dll in bin oddly), and I've verified this across a couple of installs so suspect it must be something todo with our solution/projects. The behaviour is exactly the same when deployed to Azure.

Happy to share projects etc via email if that would help

Most helpful comment

This will be available after January 6th. I'll leave this open and update the issue once the package is released.

All 13 comments

Hi @fabiocav, I have the same issue as @eastmane - I'm using Dapper and Microsoft.Data.SqlClient. The function host has multiple functions, all of them except the one using Microsoft.Data.SqlClient is throwing the specified error.

Local debugging in Visual Studio works without any problems but when deployed on Azure (using Azure DevOps pipeline) throws error. I have verified that the Microsoft.Data.SqlClient.dll and {FunctionAssemblyName}.deps.json files exists and identical in 1) local machine 2) Azure DevOps published artifacts 3) Azure Function App.

Relevant snippets from my csproj are below. I can contact you on Teams internally next week to provide more information if required.

<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<ItemGroup>
    <PackageReference Include="Autofac" Version="4.9.4" />
    <PackageReference Include="Microsoft.ApplicationInsights" Version="2.12.0" />
    <PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.4" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.10" />
    <PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" />
    <PackageReference Include="Microsoft.Extensions.Primitives" Version="3.1.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.2" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

If you could provide your deps file, that would help validate this is related to an issue we're in the process of patching.

I have emailed you the file on your Microsoft email address.

Thank you.

Actually, looking at what you're describing above, you may be running into a publishing issue.

Can you validate that, in your deployed payload, you have a file named function.deps.json in the bin folder (as opposed to {assemblyname}.deps.json

There's an updated version of the SDK (3.0.3) that addresses an issue with the publishing process. If the above seems to be the issue, can you please validate that referencing that version from https://www.myget.org/F/azure-appservice-staging/api/v3/index.json works for you?

/cc @brettsam

Thank you.

Actually, looking at what you're describing above, you may be running into a publishing issue.

Can you validate that, in your deployed payload, you have a file named function.deps.json in the bin folder (as opposed to {assemblyname}.deps.json

I don't have the file named function.deps.json anywhere in the bin folder. I will try the 3.0.3 tomorrow and let you know how it goes.

Hi @fabiocav - I can confirm that referencing 3.0.3 from the App Service staging NuGet feed works. Thank you so much for quick assessment and providing a fix.

When does it become publicly available?

This will be available after January 6th. I'll leave this open and update the issue once the package is released.

Hi @fabiocav do you think this fixes the issue I'm seeing also? If so happy to test with the updated version or provide any other details (I emailed you the project we're seeing this in).

This will be available after January 6th. I'll leave this open and update the issue once the package is released.

Was that released?

@kfrancis not yet. As mentioned above, we'll update and close the issue as soon as it is.

The package has been published to NuGet.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

christopheranderson picture christopheranderson  路  4Comments

horihiro picture horihiro  路  3Comments

silencev picture silencev  路  4Comments

svickers picture svickers  路  3Comments

helgemahrt picture helgemahrt  路  4Comments