Search code examples
c#azureazure-storageazure-functions

Azure function- Method not found in azure storage


I am using azure table storage for saving data. And I want to create the method as azure function. When i locally debug, it's work fine. When add it in azure function, I got exception error

Method not found: 'Boolean Microsoft.WindowsAzure.Storage.Table.CloudTable.CreateIfNotExists.

CloudTableClient tableClient = cloudStorageAccount.CreateCloudTableClient();
            if (tableClient != null)
            {
                CloudTable table = tableClient.GetTableReference(reference);
                table.CreateIfNotExists();
                TableOperation insertOperation = TableOperation.Insert(entity);
                table.Execute(insertOperation);
                return true;
            }

And WindowsAzure.Storage package config,

<package id="WindowsAzure.Storage" version="7.2.1" targetFramework="net461" />

Solution

  • I've just had this problem (MissingMethodException from methods in WindowsAzure.Storage 9.3.3). It was being triggered by our class-library (using WindowsAzure.Storage) which was targeted at net462.

    I checked the WindowsAzure.Storage package, and it had inside it versions for net45 and netstandard1.3. The net45 dll had methods taking CancellationTokens (like I was doing) but the methods in netstandard1.3 dll did not accept those CancellationTokens.

    I still don't know how my class library (targeted at net462) was being used by unit tests targeted at net7.0 - but the solution was easy - I just multitargeted my library to build for both net462;net7.0, and then immediately after that I could find the broken calls - and make different calls using #if NET45_OR_GREATER/#else/#endif.

    So my suggestion is: update to the latest package, and if there's any chance that you have callers in different frameworks then multitarget your intermediate-libraries to provide different binaries for each framework