Search code examples
c#azurecsx

How to reference Cosmos table API from within azure function?


I'm trying to compile a project I've written in C# script, in the azure portal(can't get any other environment to work).

I'm trying to reference the cosmos table API within my function:

#r "Newtonsoft.Json"
#r "Microsoft.WindowsAzure.Storage"
#r "Microsoft.Azure.WebJobs"
#r "Microsoft.Azure.WebJobs.Extensions"
#r "Microsoft.Azure.WebJobs.Extensions.Storage"
#r "Microsoft.Azure.Cosmos.Table"

using System;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host.Bindings.Runtime;
using Microsoft.Azure.Cosmos.Table;

But it gives me the following error:

[Error] run.csx(6,1): error CS0006: Metadata file 'Microsoft.Azure.Cosmos.Table' could not be found
2019-09-26T13:50:37.115 [Error] run.csx(14,23): error CS0234: The type or namespace name 'Cosmos' does not exist in the namespace 'Microsoft.Azure' (are you missing an assembly reference?)

How can I make azure function find the reference?


Solution

  • This namespace is not included in Azure function. You need to add the dll file to Azure function app by yourself. Refer to this article for the detailed steps.