I'm running an Azure Function locally in Visual Studio but receive the error "Could not find file 'C:\Users\kbiondi\AppData\Local\AzureFunctionsTools\Releases\4.13.0\cli_x64\Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream'. (details below).
The code that triggers this error seems to be:
let! parameters = JsonTypeProvider.AsyncLoad(req.Body.ToString())
Using let parameters = JsonTypeProvider.Load(req.Body) the function runs without problem.
I have reloaded various nuget packages and the sdk, but this problem persists.
Azure Functions Core Tools Core Tools Version: 4.0.4483 Commit
hash: N/A (64-bit) Function Runtime Version: 4.1.3.17473
[2022-05-19T18:24:10.578Z] Csproj not found in
C:\Users\kbiondi\OneDrive -
CalPERS\Repos\AzFunction_BpipeRefData\bin\Debug\net6.0 directory tree.
Skipping user secrets file configuration.
Functions:
BpipeReferenceDataRequest: [GET,POST] http://localhost:7071/api/BpipeReferenceDataRequest
For detailed output, run func with --verbose flag.
[2022-05-19T18:24:16.773Z] Host lock lease acquired by instance ID
'0000000000000000000000001F77FD18'. [2022-05-19T18:24:43.597Z]
Executing 'BpipeReferenceDataRequest' (Reason='This function was
programmatically called via the host APIs.',
Id=13a1beaf-3141-4112-a086) The Azure Function Received a
Request... Request failed with the following error:
Message: Could not find file
'C:\Users\kbiondi\AppData\Local\AzureFunctionsTools\Releases\4.13.0\cli_x64\Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream'.
Source: System.Private.CoreLib
TargetSite: Microsoft.Win32.SafeHandles.SafeFileHandle
CreateFile(System.String, System.IO.FileMode, System.IO.FileAccess,
System.IO.FileShare, System.IO.FileOptions)
StackTrace: at
Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath,
FileMode mode, FileAccess access, FileShare share, FileOptions
options) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String
fullPath, FileMode mode, FileAccess access, FileShare share,
FileOptions options, Int64 preallocationSize) at
System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode
mode, FileAccess access, FileShare share, FileOptions options, Int64
preallocationSize) at
FSharp.Data.Runtime.IO.asyncRead#219-9.Invoke(Unit unitVar) at
Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation1 ctxt, TResult result1, FSharpFunc2 part2) in
D:\a_work\1\s\src\fsharp\FSharp.Core\async.fs:line 447 at
BpipeProcess.BpipeReferenceDataRequest.Pipe #1 input at line
16#21-11.Invoke(AsyncActivation1 ctxt) at BpipeProcess.BpipeReferenceDataRequest.Pipe #1 input at line 16#20-14.Invoke(AsyncActivation1 ctxt) at
Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction)
in D:\a_work\1\s\src\fsharp\FSharp.Core\async.fs:line
104[2022-05-19T18:24:43.679Z] Executed 'BpipeReferenceDataRequest'
(Succeeded, Id=13a1beaf-3141-4112-a086, Duration=101ms)
Based on the MICROSOFT DOCUMENTATION:-
F# script (.fsx) is only supported by version 1.x of the Azure
Functions runtime. If you want to use F# with version 2.x and later
versions of the runtime, you must use a precompiled F# class library
project (.fs). You create, manage, and publish an F# class library
project using Visual Studio .
You can use in that line if wants http request e.g:- let Run(req: HttpRequestMessage, log: ILogger) =
And make sure that your folder structure looks like below format:
FunctionsProject
| - MyFirstFunction
| | - run.fsx
| | - function.json
| | - function.proj
| - MySecondFunction
| | - run.fsx
| | - function.json
| | - function.proj
| - host.json
| - extensions.csproj
| - bin
For more information please refer the aforementioned and below links:
SIMILAR ISSUE|SO THREAD
MICROSOFT DOCUMENT|Microsoft.AspNetCore.WebUtilities Namespace
BLOG|Microsoft.AspNetCore.WebUtilities FileBufferingReadStream Examples
Related
I am using the official varnish:6.5.1 docker image and have this vcl:
vcl 4.0;
import std;
backend default {
.host = std.getenv("PROXY_HOST");
.port = std.getenv("PROXY_PORT");
}
.....
When I try to run the image (with docker-compose) it instantly fails with this error:
varnish_1 | Could not delete 'vcl_boot.1612728251.581028/vgc.sym': No such file or directory
varnish_1 | Error:
varnish_1 | Message from VCC-compiler:
varnish_1 | Expected CSTR got 'std'
varnish_1 | (program line 369), at
varnish_1 | ('/etc/varnish/default.vcl' Line 13 Pos 17)
varnish_1 | .host = std.getenv("PROXY_HOST");
How is this failing? I would understand not being able to connect to the backend but the VCL parse should be fine, the documentation on the std VMOD is very simple for getenv.
What am I missing here?
EDIT
backend default {
.host = "${PROXY_HOST}";
.port = "${PROXY_PORT}";
}
in combination with
#!/bin/bash
envs=`printenv`
for env in $envs
do
IFS== read name value <<< "$env"
sed -i "s|\${${name}}|${value}|g" /etc/varnish/default.vcl
done
varnishd -f /etc/varnish/default.vcl
works as per this post but that seems hardly optimal.
Varnish Cache only supports static backends
Varnish Cache, the open source version of Varnish doesn't support dynamic backends.
When the VCL file is loaded and compiled, the .host and .port values need to be strings, not expressions.
The error message also indicates this:
Expected CSTR got 'std'
The compiler says it expects a C-string, which means something that starts with a quote, but instead it found std.
Dynamic backend support in Varnish Enterprise
Varnish Enterprise, the commercial version of Varnish, does support dynamic backends.
See https://docs.varnish-software.com/varnish-cache-plus/vmods/goto/ for more information.
Disclaimer: although Varnish Enterprise is the commercial version of Varnish Cache, you can still use it without upfront license payments if you use it on AWS, Azure or GCP.
Varnish Enterprise on AWS
Varnish Enterprise on Azure
Varnish Enterprise on GCP
I want to test my code with some data defined in an external file.
I tried the following:
namespace blub
open System
open Microsoft.VisualStudio.TestTools.UnitTesting
[<TestClass>]
type TestClass () =
[<TestMethod>]
member this.TestMethodPassing () =
let txt = System.IO.File.ReadAllText "data.txt"
Assert.IsTrue(txt.Contains "Hello");
I just created the project with dotnet new mstest -lang F# and put the data.txt file next to the Test.fs file.
However, when I run the tests with dotnet test I get the following error:
Failed TestMethodPassing
Error Message:
Test method blub.TestClass.TestMethodPassing threw exception:
System.IO.FileNotFoundException: Could not find file '/home/peter/Desktop/blub/bin/Debug/netcoreapp2.1/data.txt'.
Stack Trace:
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.File.InternalReadAllText(String path, Encoding encoding)
at System.IO.File.ReadAllText(String path)
at blub.TestClass.TestMethodPassing() in /home/peter/Desktop/blub/Tests.fs:line 11
I can of course fix this by changing the path to "../../../data.txt", but this does not seem like a stable solution -- I did not find any documentation that states how test execution affects the current directory.
Can I somehow declare my test file as a resource to be copied to the correct folder?
You will need to add the data.txt file to the fsproj and set it to copy to the output folder:
<ItemGroup>
<Content Include="data.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
If it still isn't found, you may you need to use the [<DeploymentItem("data.txt")>] against the TestClass.
This will copy the files from the output folder to the folder where the tests are executed.
I have an Azure V2 application running in Azure. For about the 3rd time now over various releases my custom dependency Injection is failing again!
This time it is worse than ever as the issue only happens when it is deployed to Azure and the logging was a nightmare to find out what was happening.
Azure Functions is currently running as follows with the usual error that it is unable to index my Functions.
018-11-10T10:41:56.091 [Information] Host Status: {
"id": "ad-api-dev",
"state": "Default",
"version": "2.0.12165.0",
"versionDetails": "2.0.12165.0 Commit hash: f9d6c271296eaae48f933c67d1df796fd4ff2a94"
}
2018-11-10T10:41:57.607 [Information] Initializing Host.
2018-11-10T10:41:57.607 [Information] Host initialization: ConsecutiveErrors=0, StartupCount=1
2018-11-10T10:41:57.644 [Information] Starting JobHost
2018-11-10T10:41:57.655 [Information] Starting Host (HostId=ad-api-dev, InstanceId=387865be-cfdf-45ca-98ba-2e0091827461, Version=2.0.12165.0, ProcessId=5140, AppDomainId=1, InDebugMode=True, InDiagnosticMode=False, FunctionsExtensionVersion=~2)
2018-11-10T10:41:57.674 [Information] Loading functions metadata
2018-11-10T10:41:57.723 [Information] 15 functions loaded
2018-11-10T10:41:58.158 [Information] Generating 15 job function(s)
2018-11-10T10:41:58.237 [Error] Error indexing method 'CompleteSimulation.Run'
Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException : Error indexing method 'CompleteSimulation.Run' ---> System.InvalidOperationException : Cannot bind parameter 'executionService' to type IExecutionService. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
at async Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexMethodAsyncCore(MethodInfo method,IFunctionIndexCollector index,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs : 277
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexMethodAsync(MethodInfo method,IFunctionIndexCollector index,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs : 167
End of inner exception
at async Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexMethodAsync(MethodInfo method,IFunctionIndexCollector index,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs : 175
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexTypeAsync(Type type,IFunctionIndexCollector index,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs : 103
2018-11-10T10:41:58.574 [Warning] Function 'CompleteSimulation.Run' failed indexing and will be disabled.
My local version runs fine as below
Azure Functions Core Tools (2.2.32 Commit hash: c5476ae629a0a438d6850e58eae1f5203c896cd6)
Function Runtime Version: 2.0.12165.0
[10/11/2018 13:35:15] Building host: startup suppressed:False, configuration suppressed: False
[10/11/2018 13:35:15] Reading host configuration file 'Y:\src\modo.solutions\Modo.Esg.Api\ModoSol.Functions.Api\bin\Debug\netstandard2.0\host.json'
[10/11/2018 13:35:15] Host configuration file read:
[10/11/2018 13:35:15] {
[10/11/2018 13:35:15] "version": "2.0"
[10/11/2018 13:35:15] }
[10/11/2018 13:35:17] Initializing extension with the following settings: Initializing extension with the following settings:
You can see I am using the same runtime version locally as Azure, So if anyone knows why my Dependency Injection would work locally but not when deployed it would be appreciated.
I am using Autofac 4.8.1 as my dependency injection container.
Thanks in advance.
BTW If anyone else has that issue of not being able to see why their Functions host is not starting follow these instructions.
Go into the Portal for your Azure function and find and enable the Live Log Streaming.
While this window is open re-deploy/publish your app.
Once thats done go into cloud explorer (Visual Studio Windows only :/) and find the logs.
If you don't have the live log streaming window open while you deploy you don't get any logs!!!
Screen shot below.
In my project, I use Nunit 2 framework.
In the build server, I use Open Cover 4.6.519 to analyze the code coverage with the following command:
"OpenCover.4.6.519\OpenCover.Console.exe"
-target:"..\..\Packages\NUnit.Runners.2.6.4\tools\nunit-console-x86.exe"
-targetargs:"/nologo /framework:net-4.0 /process:multiple /domain:multiple /noshadow /nothread <the_list_of_test_assemblies>"
-filter:"+[*]* -[*.Test]* -[*.Stub]* -[Deedle]* -[FSharp]*" -hideskipped:Filter -register -output:Build\OpenCoverResult.xml`
This is the result I get:
Executing: D:\Jenkins\workspace\SC Nightly\Packages\NUnit.Runners.2.6.4\tools\nunit-console-x86.exe
ProcessModel: Multiple DomainUsage: Multiple
Execution Runtime: net-4.0
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at NUnit.Core.ProxyTestRunner.CountTestCases(ITestFilter filter)
at NUnit.Util.AggregatingTestRunner.CountTestCases(ITestFilter filter)
at NUnit.Util.AggregatingTestRunner.Run(EventListener listener, ITestFilter filter, Boolean tracing, LoggingThreshold logLevel)
at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
at NUnit.ConsoleRunner.Runner.Main(String[] args)
Committing...
Visited Classes 0 of 617 (0)
Visited Methods 0 of 4030 (0)
Visited Points 0 of 11734 (0)
Visited Branches 0 of 6814 (0)
==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 0 of 671 (0)
Alternative Visited Methods 0 of 4663 (0)
I see an null reference exception thrown by Nunit runner, but it seems that OpenCover hangs after Nunit runner stopped.
I am thinking of some potential reasons:
The amount of test assemblies is large (59 dll files)
The assemblies are built in .Net Framework 4.5, but the framework argument of Nunit runner is net-4.0
I am using Nunit 2 which is out of date. (It is very expensive for me to upgrade to Nunit 3)
There might be something wrong with my Jenkins. I use Jenkins to run an .msbuildproj file which containing a task to execute OpenCover. When I run OpenCover command on Windows Command Prompt, it works well.
I am having troubles getting my MSBuild script transform a .tt file that references EF.Utility.CS.ttinclude.
If i run the generation from within VS2010 it works fine, but when I run my custom build script via the command line I get.
TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt"
C:\SourceControl\SVN\PathToFile\myttFile.tt(9,4): error : There was an error loading the include file 'EF.Utility.CS.ttinclude'. The transformation will not be run. The following Exception was thrown: [C:\SourceControl\SVN\PathToBuildScript\build.xml]
System.IO.FileNotFoundException: Could not find file 'C:\SourceControl\SVN\PathToFile\EF.Utility.CS.ttinclude'.
File name: 'C:\SourceControl\SVN\PathToFile\EF.Utility.CS.ttinclude'
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path)
at Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost.ReadFileContent(String fileName)
at Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost.LoadIncludeText(String requestFileName, String& content, String& location)
at Microsoft.VisualStudio.TextTemplating.Engine.ProcessIncludeDirective(Directive directive, ITextTemplatingEngineHost host)
C:\SourceControl\SVN\PathToBuildScript\build.xml(30,5): error MSB3073: The command "TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt"" exited with code 1.
If I reference the absolute path for the EF.Utility.CS.ttinclude, I get:
TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt"
EXEC : error : An expression block evaluated as Null [C:\SourceControl\SVN\PathToBuildFile\build.xml]
at Microsoft.VisualStudio.TextTemplating.ToStringHelper.ToStringWithCulture(Object objectToConvert)
at Microsoft.VisualStudio.TextTemplatinga265b58e2b114039856ebd504775f376.GeneratedTextTransformation.TransformText() in c:\SourceControl\SVN\PathToFile\myttFile.tt:line 77
at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)
C:\SourceControl\SVN\PathToBuildFile\build.xml(30,5): error MSB3073: The command "TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt"" exited with code 1.
Any help would be great :)
In short: Add the -I flag in TextTransform.exe to solve this problem like so:
Step 1:
Create an environment variable mapping to your TextTransform's EF6 Include like so:
which will create a variable VS140COMNTXTTRANSFORM that Windows understands
Step 2:
Include -I flag in the TextTransform.exe command like so:
TextTransform.exe -I "%VS140COMNTXTTRANSFORM%" -out filename.tt
Appears that the template you were running myttFile.tt failed out output anything as a result of the template being executed TransformText();
Can't really tell much without seeing what the logic is inside of myttFile.tt.
Visual Studio 11 if you
set <# template debug = true#>
and add
System.Diagnostics.Debugger.Launch();
to the code section of your template, VS 11 will launch the debugger and you can debug your t4.
sorry, just dawned on me. Chances are your template has a dependency on visual studio as its host. somewhere in your templates you have hostspecific = true.
<## template hostspecific="true" language="C#" #>