-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microsoft.Data.SqlClient: Microsoft.Data.SqlClient is not supported on this platform. #1370
Comments
I don't know if this is the reason or not, but the https://github.com/dotnet/sqlclient docs suggest 3.0 isn't supported?
But I'm not sure why my web app projects running 3.0 works and the function app does not... |
We have this same exact problem |
I had this problem on .NET Core 2.1, Functions ~2, when I tried to update to Microsoft.Data.SqlClient from System.Data.SqlClient. It worked when I tried locally using func on Linux, but failed with this exception in the cloud. |
@ngg That's the thing. I haven't imported that anywhere. It's packaged with Entity Framework from what I can tell. Upgrading/downgrading that package isn't an option. |
I think I know what is going on here. Try adding the following to your .csproj:
(in the future this workaround should not be necessary) |
@paulbatum Thanks. For anyone else having this issue and working on a mac, I had to modify what @paulbatum provided a little bit:
$(ProjectName) wasn't correct for me. It wanted the namespace I guess? In any case, aside from windows |
@paulbatum I've attempted to use this solution with no luck. I've verified that when deployed the functions.deps.json is present and accurate, however I still get the same exception as above. I have tried a few setups to verify that the issue happens regardless of if my Azure Function project directly references Microsoft.Data.SqlClient or not. Any other suggestions if this workaround doesn't solve the issue? |
@kaeus you're probably hitting Azure/azure-functions-vs-build-sdk#333. You're also need to add the following to work around that .NET Core 3.0 SDK bug:
@paulbatum that's awesome that there's hope for that not being needed in the future. Do you have an issue, version, and/or ETA for the fix? There's a long (closed but active) issue, Azure/azure-functions-host#3568, with lots of people reporting the issue but no updates from Microsoft so it was seeming this wasn't ever going to be fixed. |
@IGx89 Thanks, that seems to have wrapped up the issue for me (combining that with the previous solutions)! |
I'm having a few problems with this work around. I can see the file getting copied to the output directory with the relevant detail to function.deps.json, but my DI assembly scanning is then failing to pick up all of my dependencies. This is my assembly scanning code that then registers the dependencies using Scrutor with the built in .NET Core DI Container:-
I've tried the copy command with the actual name of the file too (as opposed to the name function.deps.json) but I'm still not able to resolve my dependencies, despite all the dependencies being configured. Apologies for this not quite being related to the main problem but it's the only place I could ask the question. Thanks |
For anyone hitting this problem on "zip deployed" (from Visual Studio) azure functions the final .csproject section required is the following:
@IGx89 your suggestion fixed the problem, but with "zip deployed" azure functions the directory move was being done after the publishing. |
@iRubens all my functions are zip deployed as well but the zipping is done as a separate command after |
If you are using Azure DevOps to publish with the DotNetCoreCLI task you can set zipAfterPublish to true that should do that automatically. I don't know of any way to do that via |
@IGx89 at the moment we're deploying our functions directly from Visual Studio (I've updated my comment). Unfortunately don't know either if there's any command for the CLI to obtain the same result. |
For those of you working around this -- the deps.json file should now be auto-copied when using Microsoft.NET.Sdk.Functions version 3.0.0-preview1. There is still a problem with having the runtimes folder moved to under the bin folder during publish -- I'm looking into that now, but the workaround above (#1370 (comment)) should work. |
My azure function stopped pubishing after adding above code to csproj file : https://stackoverflow.com/questions/58833050/azure-functions-runtime-exception-the-type-initializer-for-system-data-sqlclien "Publish has encountered an error. |
@shailendrarampal -- what OS are you running on? Note that you should not need the deps.json lines anymore when using 3.0.0-preview1. |
I am using windows 10 64bit! |
This line should be taking care of that: |
|
It worked for me by adding below code in csproj file :
Thank you. |
I've just pushed Microsoft.Net.Sdk.Functions 3.0.0-preview2. I believe this package now handles all the problems mentioned in this issue. If you could try removing the workarounds and using that package, that'd be helpful. I'm going to close this now, but let me know if something hasn't been fixed and I can re-open (or create a separate issue). |
I can confirm both issues are fixed now for me (under Functions v3-preview, .NET Core SDK 3.0), thanks a lot @brettsam! |
FWIW, I tried the 3.03 package in my azure function project that is getting the error and there was no change. The error still occurs. I also tried the Microsoft.NET.Sdk.Functions.3.0.4 package and the error still occurs with that. My project is targeting '.NETFramework,Version=v4.8' |
I am still seeing this issue also. I am migrating from Core 2.2 to Core 3.1 Confirmed my function app is running a ~3.x runtime: I see this when I try to execute a function:
What's a bit concerning here is that it is trying to use the correct client ( |
I was able to get this working by downgrading the functions sdk to 3.0.2 (which is odd considering the fix was supposed to go to into 3.0.3) |
@daunish had same issue and is now working on 3.0.5 - netcoreapp3.0 |
Hi, I've been trying all the tips in this thread so far for a whole day but still getting It has been working for the past couple of years and only when I updated my .Net Core version did this error start appearing (I believe). Here are my installed .Net Core versions.
Microsoft.NET.sdk.functions: 3.0.6 (Also tried 3.0.2 as suggested) Any further advice would be greatly appreciated. Edit: Started happening to my colleague. Everyone scared to change anything now. Is this an actual bug or are we all doing something wrong? |
To overcome "Microsoft.Data.SqlClient is not supported on this platform" exception in Azure (Linux) without using "Microsoft.NET.Sdk.Functions" nuget package, do the following (in csproj file).
Targeting netcoreapp3.1 and Function Runtime v3 (Azure defaults to 3.0.13113) |
Just a quick note - we consider the |
@paulbatum Consider separating MSBuld related task into separate package. Light, portably and not tying to any particular stack is very appealing to a lot of consumers. Regardless, focus on developer experience and integration is what set Azure apart from others !!! And makes it easy to use !!! |
@WinInsider Yes what you're asking for makes sense, there is definite room for improvement in terms of the minimal dependency surface area when writing a .NET based function. Anyway I don't want to derail this thread further. For the folks still reporting problems when running on the latest package (3.0.7 at time of writing) and targetting netcoreapp3.1, please file a new issue and link back to this one. Fill out the issue template and make sure you include additional relevant details such as the contents of your csproj. |
I have the problem with the 3.0.7 runtime, although I can only reproduce the problem when running in a container. Non container locally and in Azure seems to work fine, but I love containers, so it would be nice to get it working there too. I commented with a github repo that can reproduce it when running with Visual Studio on this newer issue Azure/azure-functions-host#5950 |
Interesting enough, I just tried within Visual Studio as a Release build and it worked fine. I am not sure why Release works and Debug doesn't. I was also able to successfully to successfully build the container from Azure Pipelines and run it in an Azure App Service Linux container instance. I'm still not sure why it doesn't work for me with a Visual Studio debug build, but that isn't a big issue for me now since I can run it in production. |
I just confirmed that is in "Microsoft.NET.Sdk.Functions" Version="3.0.8". Move back to 3.0.7 and goes away. |
+1...been banging my head against my desk for several hours now trying to figure out why I was getting the platform not supported message when all indication was that it was working. After downgrading the SDK to v3.0.7, the SQL client is working. HOWEVER, after digging around through some other things, I stumbled upon what may be a caveat or potentially a regression in the SDK tooling that I was able to work around and get the SqlClient package working with v3.0.8 of the SDK. It appears to me that in v3.0.7, when you build your function app the build target places the So with v3.0.8, my current workaround is to add a post-build target that is similar to what IGx89 mentioned in an earlier comment. Note, however, that the target is post-build, not post-publish. The difference with my approach is that the files are copied after build, which supports local debugging of your function app while also not stepping on the toes of what the publish target does. The downside is that there are multiple copies of runtime binaries in your build directories, but the upside is that this won't affect what is copied to the publish directory during that target. <Target Name="PostBuild" AfterTargets="AfterBuild">
<Exec Command="xcopy /E /I /Q /Y $(OutDir)runtimes $(OutDir)bin\runtimes" />
</Target> The azure-functions-vs-build-sdk repository doesn't seem to be very well maintained in terms of tagging their releases and being transparent about what commits are going into which releases. As an example, see issue #438. I wasn't able to spend enough time to follow what changed from v3.0.7 to v3.0.8...but my hunch is that there was some sort of regression. |
@TheHokieCoder This worked for me! Thanks a ton :) |
Downgrading to 3.0.7 worked for me |
@paulbatum Do we need a new issue for 3.0.8 or are you guys aware of the problem? |
Azure is such a shit show, they break stuff every minor patch and you spend hours or days trying to figure out wtf is going on. Its like basically never upgrade your packages. |
This was an issue with the build tooling that came with 3.0.8 -- Issues and PR are here:
|
My fix was changing my project from
To
Then updating package |
Microsoft.NET.Sdk.Functions to v 3.0.9 fixed the problem |
Can't upgrade to v3.0.9 because of this issue :( |
Still having the same problem with Microsoft.NET.Sdk.Functions v. 3.0.9. |
So i just ran into the issue, easy to understand if this is beta, but isn't everything with issues officially released at first it seems looking at the date of the original post this has been going on for over a year now? Last comment only 10 hours ago... |
@anthonychu to understand what is happening, we'd need the details. @ZooDoo4U can you please open a new issue with details of all version used, exception stacks, etc? we can take a closer look then. Will lock this issue as there have been tooling and runtime updates to address the original root cause, so any new instances will need to be investigated separately. |
Please include your csproj in the repro as that helps determine what could be going on. |
If anyone runs into this while using the functions CLI to install extensions ( <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<WarningsAsErrors></WarningsAsErrors>
<DefaultItemExcludes>**</DefaultItemExcludes>
</PropertyGroup>
<!-- Workaround for https://github.com/Azure/Azure-Functions/issues/1370 -->
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Move SourceFiles="$(OutDir)/extensions.deps.json" DestinationFiles="$(OutDir)/function.deps.json" />
</Target>
<ItemGroup>
<!-- ...(other dependencies)... -->
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.0" />
</ItemGroup>
</Project> This workaround specifically applies to C# scripting and non-.NET languages which aren't using extension bundles. |
I am migrating from a functions 2.0 project to a 3.0 project. I followed the steps outlined here but am unable to run the project (fails at runtime)
Error:
Here is my package dependencies:
However, I suspect that this error is coming from my Database Project which is using Entity Framework 3.0. Here's those dependencies:
I am not explicitly pulling in
Microsoft.Data.SqlClient
anywhere within my project / solution. I did find the reference in the Entity Framework packages though, so I assume it's coming from that.The only other thing worth mentioning here is that my Web App (running dotnet 3.0) is able to utilize the same database project without any issues.
dotnet --info
The text was updated successfully, but these errors were encountered: