Azure / azure-cosmos-table-dotnet

.NET SDK for Azure Cosmos Table API
14 stars 6 forks source link

local project runs fine, but in Azure Web app as a web job, it fails #45

Open robbiemu opened 4 years ago

robbiemu commented 4 years ago

We are continuously addressing and improving the SDK. Please describe your issue along with the following information:

I am not able to run my webjob on azure because of dependencies in Microsoft.Azure.Cosmos.Table: 1.0.6 (currently that's latest stable release).

** SDK version csproj:

    <TargetFramework>net48</TargetFramework>
    <LangVersion>8.0</LangVersion>

app.config:

        <supportedRuntime version="v4.0" />

Microsoft.Azure.Cosmos.Table: 1.0.6

** Issue reproduce steps

                    CloudStorageAccount tableAccount = Microsoft.Azure.Cosmos.Table.CloudStorageAccount.Parse(Instance.ConnectionString);
                    Instance.StorageAccount = tableAccount;
                    CloudTableClient tableClient = tableAccount.CreateCloudTableClient();
                    Instance.Client = tableClient;

** Whether the issue is consistent or sporadic 0% locally (at least on my mac dev environment, with mono 6.8.x up-to-date) 100% on Azure

** Environment Summary on Azure Web App: Configuration > General Settings Stack: .NET .NET Framework Version: V4.7

** Any other context, such as stack trace or log.

[04/14/2020 06:36:16 > 71b93c: ERR ] Unhandled Exception: Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.ConsumeImages ---> System.TypeInitializationException: The type initializer for 'ImageConsumer.Functions' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Threading.Tasks, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
[04/14/2020 06:36:16 > 71b93c: ERR ]    at Microsoft.Azure.Cosmos.Table.CloudTableClient..ctor(StorageUri storageUri, StorageCredentials credentials, TableClientConfiguration configuration)
[04/14/2020 06:36:16 > 71b93c: ERR ]    at Microsoft.Azure.Cosmos.Table.CloudStorageAccountExtensions.CreateCloudTableClient(CloudStorageAccount account, TableClientConfiguration configuration)

What I find bizarre is that I cannot find a way around it without updating Microsoft.Azure.Cosmos.Table to 2.0.0-preview (which does work in the Azure webjob environment). I tried installing the nuget package for 4.0.11, 4.3.0 - and providing a binding redirect. I saw no change though (other than the error first failing to find the redirect version, then the 4.0.10.0 version). Also tried 4.0.10, but the install aborts with "Package restore failed. Rolling back package changes" and no error message to indicate what is going on. I thought that might be a mono issue.. but it is also true when I copy the project onto my virtual box and run it with visual studio 2019 in windows 10.

There is no system.threading.tasks reference I could add.

I also noticed that when I set the csproj to v4.7 exactly I can reproduce the error as a warning like "ound conflicts between different versions" but then it still runs locally anyway. Trying a different version like 4.7.1 also does not resolve the issue on the remote environment.