Azure powershell function stopped working (no identified changes) with a error "Could not load file or assembly 'Azure.Core, Version=1.5.1.0 "

Viewed 217

A number of our azure functions (within function app) stopped working in early november. While im sure its something simple we cannot identify and changes that have been made. This is the code (up to the line to error on - new-AzStorageContext)

using namespace System.Net


# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a LIPA Open Day Data message."
$OpenDayData = "$((Get-Date -format yyyy-MMM-dd-ddd` HH-MM-ss-fff).ToString()).json"
$TargetContainerName = $env:ODLTargetContainerName

# Interact with query parameters or the body of the request.
$message = $Request.Body.Message

if ($message) {

    write-host "Instantiating storage context"
    $ctx = New-AzStorageContext -ConnectionString $env:AzureWebJobsStorage

and this ie the error:

2020-12-04T17:37:58.516 [Error] ERROR: Could not load file or assembly 'Azure.Core, Version=1.5.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'. The system cannot find the file specified.Exception             :Type       : System.IO.FileNotFoundExceptionMessage    : Could not load file or assembly 'Azure.Core, Version=1.5.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'. The system cannot find the file specified.FileName   : Azure.Core, Version=1.5.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8TargetSite : Void .ctor(System.Action`1[System.String])StackTrace :at Microsoft.Azure.Commands.Common.Authentication.AzureEventListener..ctor(Action`1 action)at Microsoft.Azure.Commands.Common.Authentication.Factories.AzureEventListenerFactory.GetAzureEventListener(Action`1 action)at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.SetupDebuggingTraces()at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.BeginProcessing()at System.Management.Automation.Cmdlet.DoBeginProcessing()at System.Management.Automation.CommandProcessorBase.DoBegin()Source     : Microsoft.Azure.PowerShell.AuthenticationHResult    : -2147024894CategoryInfo          : NotSpecified: (:) [New-AzStorageContext], FileNotFoundExceptionFullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet.NewAzureStorageContextInvocationInfo        :MyCommand        : New-AzStorageContextScriptLineNumber : 18OffsetInLine     : 12HistoryId        : 1ScriptName       : D:\home\site\wwwroot\LogOpenDayActivity\run.ps1Line             :     $ctx = New-AzStorageContext -ConnectionString $env:AzureWebJobsStoragePositionMessage  : At D:\home\site\wwwroot\LogOpenDayActivity\run.ps1:18 char:12+     $ctx = New-AzStorageContext -ConnectionString $env:AzureWebJobsSt …+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot     : D:\home\site\wwwroot\LogOpenDayActivityPSCommandPath    : D:\home\site\wwwroot\LogOpenDayActivity\run.ps1InvocationName   : New-AzStorageContextCommandOrigin    : InternalScriptStackTrace      : at <ScriptBlock>, D:\home\site\wwwroot\LogOpenDayActivity\run.ps1: line 18Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: ERROR: Could not load file or assembly 'Azure.Core, Version=1.5.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'. The system cannot find the file specified.Exception             :Type       : System.IO.FileNotFoundExceptionMessage    : Could not load file or assembly 'Azure.Core, Version=1.5.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'. The system cannot find the file specified.FileName   : Azure.Core, Version=1.5.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8TargetSite : Void .ctor(System.Action`1[System.String])StackTrace :at Microsoft.Azure.Commands.Common.Authentication.AzureEventListener..ctor(Action`1 action)at Microsoft.Azure.Commands.Common.Authentication.Factories.AzureEventListenerFactory.GetAzureEventListener(Action`1 action)at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.SetupDebuggingTraces()at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.BeginProcessing()at System.Management.Automation.Cmdlet.DoBeginProcessing()at System.Management.Automation.CommandProcessorBase.DoBegin()Source     : Microsoft.Azure.PowerShell.AuthenticationHResult    : -2147024894CategoryInfo          : NotSpecified: (:) [New-AzStorageContext], FileNotFoundExceptionFullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet.NewAzureStorageContextInvocationInfo        :MyCommand        : New-AzStorageContextScriptLineNumber : 18OffsetInLine     : 12HistoryId        : 1ScriptName       : D:\home\site\wwwroot\LogOpenDayActivity\run.ps1Line             :     $ctx = New-AzStorageContext -ConnectionString $env:AzureWebJobsStoragePositionMessage  : At D:\home\site\wwwroot\LogOpenDayActivity\run.ps1:18 char:12+     $ctx = New-AzStorageContext -ConnectionString $env:AzureWebJobsSt …+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot     : D:\home\site\wwwroot\LogOpenDayActivityPSCommandPath    : D:\home\site\wwwroot\LogOpenDayActivity\run.ps1InvocationName   : New-AzStorageContextCommandOrigin    : InternalScriptStackTrace      : at <ScriptBlock>, D:\home\site\wwwroot\LogOpenDayActivity\run.ps1: line 18Exception: Could not load file or assembly 'Azure.Core, Version=1.5.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'. The system cannot find the file specified.Stack:    at Microsoft.Azure.Commands.Common.Authentication.AzureEventListener..ctor(Action`1 action)at Microsoft.Azure.Commands.Common.Authentication.Factories.AzureEventListenerFactory.GetAzureEventListener(Action`1 action)at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.SetupDebuggingTraces()at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.BeginProcessing()at System.Management.Automation.Cmdlet.DoBeginProcessing()at System.Management.Automation.CommandProcessorBase.DoBegin()
1 Answers

Please check the requirements.psd1 of your function. Check if it was modified by others. enter image description here

And then restart your function app.

If still show same error message, I think you can create another function with same code to implement your requirement because some files may be removed(or modified) by some one.

Related