Azure Functions ScriptHost initialization failed error - azure

I'm attempting to write a simple Azure Function app and I want to reference some other existing projects in my VS 2017 solution. These other projects have a reference to some custom logging code which in turn references the Nuget packages Microsoft.Extensions.Logging, Microsoft.Extensions.Logging.Console and Microsoft.Extensions.Logging.Debug.
When I start my functions app in VS2017, I get the following error:
[3/21/2018 5:42:12 PM] ScriptHost initialization failed
[3/21/2018 5:42:12 PM] System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
It doesn't matter whether I directly reference the above three Nuget packages in my Functions project or not. I'm using the 1.0.9 version of Azure Functions.
I've posted a highly simplified example of a project showing this error in a GitHub repo here: https://github.com/chriswill/FunctionDemo

Thanks for reporting. Issue is being tracked here

Related

Azure Function err: microsoft.Azure.WebJobs.Extensions.Http

I just had the same 'TestTrigger' can't be invoked from Azure WebJobs SDK. Is it missing Azure WebJobs SDK attributes?"-error in a v4 function running .Net 6.0.
error :
"System.Private.CoreLib: Could not load file or assembly 'Microsoft.Azure.WebJobs.Extensions.Http, Version=3.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified."
enter image description here
It think this issue is misleading.
I changed TargetFramework from netcoreapp3.1 to net6.0 and this issue started to appearing.
I was looking for solutions in the web, without any success. In the end I created new Azure Function and copy code step by step.
It occurred that for my case I needed to
remove dependencies
add _FunctionsSkipCleanOutput property
In the screenshot below please focus on Microsoft.Extension part.

Azure Functions Powershell: module could not be loaded via managed dependencies

We are having trouble importing a library form powershellgallery.com: IntuneWin32App.
The error msg goes as follows:
"ERROR: The 'New-IntuneWin32AppPackage' command was found in the module 'IntuneWin32App', but the module could not be loaded."
We are running Azure functions 3, Powershell 7.1.
IntuneWin32App is imported via managed dependencies. Specified in the "requirements.psd1" as follows:
'IntuneWin32App' = '1.*'
We have tried several solutions for related issues to this error but none could help us.
EDIT: detailed output: https://pastebin.com/t3kBF00A
We also did a deployment of the function to the cloud environment and we are retrieving the same issue over there.
[2021-07-30T06:54:54.792Z] ERROR: Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
Does the module require authentication? It seems it's trying to launch a winforms window which isn't available in PowerShell 7.
Is there another authentication mechanism you can use with that module like service principal or certificate that prevents the window?

Publishing Web App to Azure

I have a web app on Azure. When I publish an update to it using WebDeply it doesn't work. I get a 502.5 Process Failure error. Upon investigation the content of the error is:
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Abstractions, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Web.Program.Main(String[] args)
Does anyone know why I would be getting this?
It works locally but not when published. The most recent update I did to the AspNetCore ddls was done as part of this release where I upgraded the NuGet packages reference to be the latest patch fixes ie. from 2.0.0 to 2.0.2. Is it something I did wrong?
I eventually solved the issue by using an FTP, deleting all of the DLLs in the website folder and re-publishing the application.
Seems Web Publish or VS decided not to update those files for some reason.
Addional information for Adam Stapleton.
As Adam Stapleton mentioned it seems that Web publish or VS doesn't update the related files. If we update the AspNetCore, I recommend that we could remove the Azure WebApp files during republish the WebApp. We also could do this with VS. For more detail information, please refer to the screenshot.

Azure MVC Continous Integration Vs Publishing - missing Owin dll

I have a strange issue.
When I publish my MVC site to Azure it works.
When I hook it up to deploy using continuous integration on check-in I get a missing dll:
Could not load file or assembly 'Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I can't work out what is going on as the code base is always the same!
All, after reading a couple of comments I have uploaded the following images. All my Owin references are coming from Nuget but it looks like I have a few different version numbers of Own references. I don't know why this would be as the web project.
I have searched my project for the word Owin and found there are very few references and, as you can see in this image, there are 3 different version numbers for various DLLs that are related to Owin:
Also, here are all the references to Owin in my Visual Studio Online build log:
Maybe someone can comment on why there are varying version?
thanks
Russ

Could not load file or assembly 'msshrtmi' - when publishing Windows Azure Websites

I'm having an issue as below:
Could not load file or assembly 'msshrtmi, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'msshrtmi, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'msshrtmi, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
The issue happens only when publishing to Windows Azure Websites (WAWS). I want to detect whether I am running in Windows Azure mode or not. Is this possible in WAWS? This error is happening only when I call Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.IsAvailable.
I'd assume that the WAWS environment would have the Azure SDK installed, right? Or is this only available for Cloud services?
I've looked at some solutions telling you to manually include it in x64 or x86 version, but I would like not to be limited that way, or similar workarounds.
I encountered this same error when publishing a Web App. After trying every other solution on the web, the following finally worked for me:
In the Azure Portal, select your Web App. Select 'Settings > Application settings'. Change the Platform value from 32-bit to 64-bit. Re-publish.

Resources