Azure functions failing when upgrading to 1.0.8 - azure

Using the latest version of VS 2017 I
Create a new azure functions project.
Add a timer trigger function
Upgrade to latest (1.0.8) azure functions nuget package
Add a reference to azure storage for creating table client
run the project, and it just failes on load.
A ScriptHost error has occurred [06.03.2018 20.46.05] Exception while
executing function: Function1. FunctionApp2: Could not load file or
assembly 'Microsoft.WindowsAzure.Storage, Version=8.6.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or
load a specific file. (Exception from HRESULT: 0x80131621).
System.Private.CoreLib: Could not load file or assembly
'Microsoft.WindowsAzure.Storage, Version=8.6.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'.
Sample code:
[FunctionName("Function1")]
public static void Run([TimerTrigger("0 */5 * * * *", RunOnStartup = true)]TimerInfo myTimer, TraceWriter log)
{
log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
var storageAccount = CloudStorageAccount.Parse("[someConnectionString]");
var tbc = storageAccount.CreateCloudBlobClient();
}
How can I fix this?

Could not load file or assembly 'Microsoft.WindowsAzure.Storage
According to your error message , it seems that you have missed the Microsoft.WindowsAzure.Storage assembly or the package version conflict. You could check whether you have used the same package of different versions. Check the compatibility of dependencies of Microsoft.NET.Sdk.Functions 1.0.8 . Or try to uninstall then reinstall the Microsoft.NET.Sdk.Functions package.
I follow your steps to install Microsoft.NET.Sdk.Functions 1.0.8 from Manage Nuget Packages in Visual Studio. Then I run the TimeTrigger directly. Everything works fine. I could see the Microsoft.WindowsAzure.Storage package in dependencies.
And you could check the project.assets file in your Azure function folder.
The running result:
Besides, this article have some similar issues, you could refer to.

Related

Azure Function Java : The binding type(s) blobTrigger are not registered

Have created a blob trigger in java by following functions-reference-java. The trigger works locally, however in the portal it says
Error: The binding type(s) 'blobTrigger' are not registered.
Have followed these instructions to update the azure-function-core
My Function app details:
Runtime version: 2.0.12246.0 (~2)
Plaftform: 64-bit
How to get the extensions installed ?
Function app error
I resolved it myself. extensions.csproj was missing from my pipeline.
I manually added it via the portal and ran the following in the kudu prompt.
dotnet build extensions.csproj -o bin --no-incremental --packages D:\home\.nuget

Azure KeyVault nuget package issues

When I installing Azure.KeyVault package version 3 alpha, I'm getting the following runtime exception:
Could not load file or assembly 'Microsoft.Azure.KeyVault, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)
Downgrading this package to latest stable 2.3.2 causes another error:
Here is my package list with dependencies:
Any ideas or workaround on this?
Seems like the problem was inside v2 runtime:
https://github.com/Azure/azure-functions-host/issues/2854
My decision was to turn roll back to v1 Functions, cause I found another issues during the KeyVault implementation by this article:
https://learn.microsoft.com/en-us/azure/app-service/app-service-managed-service-identity
Here is the issue:
https://github.com/Azure/azure-functions-host/issues/2852

Azure Function Nuget Cache restore failing with "The user name or password is incorrect."

I have an Azure Function I deploy as a part of an ARM template. This Azure Function references a few external .NET DLLs. I have added the reference to these DLLs in the project.json file:
project.json:
{
"frameworks": {
"net46": {
"dependencies": {
"Microsoft.IdentityModel.Clients.ActiveDirectory":"3.13.8",
"Newtonsoft.Json": "10.0.2",
"Microsoft.CrmSdk.CoreAssemblies" : "8.2.0.2"
}
}
}
}
When I click run, the Nuget Cache restore is kicked off. It fails with "The user name or password is incorrect."
The strange thing is the Nuget Packages are being copied to the Functions Nuget cache correctly, but the project.lock.json file is failing to be created. It appears the username / password error is thrown after the Nuget cache restore completes and when Azure tries to write the project.lock.json file. The compile then fails as the project.lock.json file is not created.
2017-11-14T21:06:34.892 Restoring packages.
2017-11-14T21:06:34.892 Starting NuGet restore
2017-11-14T21:06:36.239 Function started (Id=1340feea-174d-4bee-97f2-e06afc2e2d6e)
2017-11-14T21:06:36.239 Package references have been updated.
2017-11-14T21:06:36.239 Restoring packages.
2017-11-14T21:06:36.239 Starting NuGet restore
2017-11-14T21:06:36.955 Restoring packages for D:\home\site\wwwroot\ProvisionUserToCRM\project.json...
2017-11-14T21:06:37.456 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel.clients.activedirectory/index.json
2017-11-14T21:06:37.486 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel.clients.activedirectory/3.13.8/microsoft.identitymodel.clients.activedirectory.3.13.8.nupkg
2017-11-14T21:06:37.705 CACHE https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
2017-11-14T21:06:37.705 CACHE https://api.nuget.org/v3-flatcontainer/newtonsoft.json/10.0.2/newtonsoft.json.10.0.2.nupkg
2017-11-14T21:06:37.800 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.crmsdk.coreassemblies/index.json
2017-11-14T21:06:37.800 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.crmsdk.coreassemblies/8.2.0.2/microsoft.crmsdk.coreassemblies.8.2.0.2.nupkg
2017-11-14T21:06:37.881 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel/index.json
2017-11-14T21:06:37.881 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel/6.1.7600.16394/microsoft.identitymodel.6.1.7600.16394.nupkg
2017-11-14T21:06:38.002 Installing Microsoft.IdentityModel 6.1.7600.16394.
2017-11-14T21:06:38.362 Installing Microsoft.CrmSdk.CoreAssemblies 8.2.0.2.
2017-11-14T21:06:38.939 Restoring packages for D:\home\site\wwwroot\ProvisionUserToCRM\project.json...
2017-11-14T21:06:39.113 Installing Newtonsoft.Json 10.0.2.
2017-11-14T21:06:39.255 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel.clients.activedirectory/index.json
2017-11-14T21:06:39.284 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel.clients.activedirectory/3.13.8/microsoft.identitymodel.clients.activedirectory.3.13.8.nupkg
2017-11-14T21:06:39.455 CACHE https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
2017-11-14T21:06:39.455 CACHE https://api.nuget.org/v3-flatcontainer/newtonsoft.json/10.0.2/newtonsoft.json.10.0.2.nupkg
2017-11-14T21:06:39.470 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.crmsdk.coreassemblies/index.json
2017-11-14T21:06:39.470 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.crmsdk.coreassemblies/8.2.0.2/microsoft.crmsdk.coreassemblies.8.2.0.2.nupkg
2017-11-14T21:06:39.490 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel/index.json
2017-11-14T21:06:39.502 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel/6.1.7600.16394/microsoft.identitymodel.6.1.7600.16394.nupkg
2017-11-14T21:06:39.642 Installing Microsoft.IdentityModel.Clients.ActiveDirectory 3.13.8.
2017-11-14T21:06:41.211 Installing Microsoft.IdentityModel 6.1.7600.16394.
2017-11-14T21:06:42.367 Installing Microsoft.CrmSdk.CoreAssemblies 8.2.0.2.
2017-11-14T21:06:46.398 Installing Microsoft.IdentityModel.Clients.ActiveDirectory 3.13.8.
2017-11-14T21:06:49.197 Installing Newtonsoft.Json 10.0.2.
2017-11-14T21:06:52.171 The user name or password is incorrect.
2017-11-14T21:06:52.189
2017-11-14T21:06:52.189
2017-11-14T21:06:52.189 Packages restored.
2017-11-14T21:06:52.500 Script for function 'ProvisionUserToCRM' changed. Reloading.
2017-11-14T21:06:52.813 run.csx(2,18): error CS0234: The type or namespace name 'IdentityModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
2017-11-14T21:06:52.813 run.csx(3,8): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
Does anyone know why this error is displayed? It seems to come intermittently for me. Seems like a bug in Azure Functions. Are there any known work arounds?
I found enabling 'Slots' preview feature on Azure Functions actually resolves this issue, but 'Slots' will not work for me as they are not compatible with Azure Logic Apps.
Looks like Microsoft has confirmed this is a bug in Azure Functions
https://github.com/Azure/Azure-Functions/issues/590
The only work around I am aware of is to:
enable slots feature
keep re deploying your ARM template until it works
(I did not verify this) but I suspect it would work if you manually generated and dropped the lock file to the Functions file system. You could generate the lock file locally with visual studio. I suspect this would work because from what I observed is the NuGet packages seem to be restored correctly, and the error comes during the write of the JSON file. The compiler must reference the lock file rather than the actual NuGet cache when trying to compile (hence why the error is coming even though the DLL actually exists).

Entity framework assembly issue

When i am try to use bulkinsert method on EF by using entityframework.bulinsert dll getting Error message _"Could not load file or assembly 'EntityFramework.MappingAPI, Version=5.0.0.6, Culture=neutral, PublicKeyToken=7ee2e825d201459e' or one of its dependencies. The system cannot find the file specified".
It simply means the assembly is missing in your project AND/OR 'EntityFramework.MappingAPI, Version=5.0.0.6, is missing in your References.
Download the 'EntityFramework.MappingAPI, Version=5.0.0.6, from HERE
Extract the dll's from the folder and add a reference to the appropriate one that is version 5, from your solution.
OR
To install EntityFramework.MappingAPI, run the following command in the Package Manager Console
PM> Install-Package EntityFramework.MappingAPI -Version 5.0.0.6
This will install and automatically add a reference to it.``

SubSonic "Version" fails due to missing dependencies

I am using SubSonic 2.1 Final but having problems running "Version" with the SubCommander. I think this problem began when I installed SQL Server 2008 on my local machine and removed 2005.
This is the error I get:
ERROR: Trying to execute Version
Error Message: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.SmoEnum, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.SqlServer.SmoEnum, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetDbCollation(String dbname)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.GetDbComparer(Boolean inServer)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.InitializeStringComparer()
at Microsoft.SqlServer.Management.Smo.AbstractCollectionBase.get_StringComparer()
at Microsoft.SqlServer.Management.Smo.SimpleObjectCollectionBase.InitInnerCollection()
at Microsoft.SqlServer.Management.Smo.SmoCollectionBase.get_InternalStorage()
at Microsoft.SqlServer.Management.Smo.SmoCollectionBase.GetObjectByKey(ObjectKeyBase key)
at Microsoft.SqlServer.Management.Smo.DatabaseCollection.get_Item(String name)
at SubSonic.SubCommander.DBScripter.ScriptSchema(String connectionString) in C:\svn\subsonicproject\trunk\SubCommander\DBScripter.cs:line 51
at SubSonic.SubCommander.Program.ScriptSchema() in C:\svn\subsonicproject\trunk\SubCommander\Program.cs:line 696
at SubSonic.SubCommander.Program.Main(String[] args) in C:\svn\subsonicproject\trunk\SubCommander\Program.cs:line 68
Anybody knows how to make this work?
You probably have to compile SubCommander with the SqlServer 2008 version of Microsoft.SqlServer.Management.Smo dlls
I made this work by downloading the latest source and build it on my machine. Now it works great.

Resources