question

NateJones-2280 avatar image
0 Votes"
NateJones-2280 asked AnuragSingh-MSFT edited

Azure functions project getting PlatformNotSupportedException after updating System.Diagnostics.PerformanceCounter from 4.7.0 to 5.0.0 (C#lib, netcoreapp3.1, v3 funcs)

I've got an azure functions (c# lib, netcoreapp3.1) proj that was happily using perf counters while on System.Diagnostics.PerformanceCounter 4.7.0, but I've run into problems trying to upgrade to the System.Diagnostics.PerformanceCounter 5.0.0 package.

The first issue was dll load exceptions. The perf counter dll wasn't making its way into my function's bin dir, but I worked around that by adding <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> to my csproj file.

Unfortunately, while the dll loads now, it throws a PlatformNotSupportedException as soon as I try to construct a perf counter (both in azure and the azure emulator). I didn't think azure functions blocked perf counters (especially since 4.7.0 seemed to work fine for me).

My project's netcoreapp3.1 and I'm using Microsoft.NET.Sdk.Functions 3.0.11 (issue also repro'd on .13). I'm on functions version v3 and windows OS, of course.

azure-functions
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AnuragSingh-MSFT avatar image
0 Votes"
AnuragSingh-MSFT answered AnuragSingh-MSFT edited

Hi @NateJones-2280,

Welcome to Microsoft Q&A!

Apologies for the delayed response. I was able to repro this issue and here is a workaround which should help you. You can include the following in your .csproj under PropertyGroup to specify the rid as Windows. More information about resource identifier (rid) is available here.

 <runtimeidentifier>win</runtimeidentifier>

PerformanceCounter is specific to Windows and this rid specifies the corresponding assembly to be loaded from nuget package. Based on my investigation, the issue did not happen with version 4.7 of PerformanceCounter dll because it was being loaded from the Azure Functions cli tools.
While the workaround above helped to resolve this error in my repro with version 5.0.0 of the dll, I am reaching out to Function App team for more information.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @NateJones-2280,
I have also filed this issue for Functions App on Github here. Please feel free to comment/add details on the Github issue for further details.

0 Votes 0 ·