4

I am trying to create an azure function program with a service bus queue trigger template using a csx file. But I am having issues resolving dependencies. To be honest, i am very confused about the project structure that is mentioned in [this doc] (https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp). I've tried two approaches.

First approach... Create a folder named MyAzureFunc in a visual studio code and manually add a function.json , project.json, project.lock.json, and run.csx. Then, outside of the MyAzureFunc folder I add a host.json and local.settings.json. This approach leads to dependency issues.

Folder Structure

Second approach... Create an Azure Function project with service bus queue template in visual studio code that generates a completely different folder and project structure. I'll then remove most of the auto-generated files and manually add in the structure mentioned in the first approach. This still leads to dependency issues.

Service Bus Queue Project Structure

Some possible reasons i believe this could be happening is the following... 1. Framework versions - my project.json calls for "net46", but when i create an azure function in visual studio code using the service bus queue template it implements "netcoreapp2.1" 2. The need to run some command to recognize the package dependencies 3. Some project configuration needed to work with csx

I believe the important file here is the project.json. Below is the code...

{
    "frameworks": {
      "net46":{
        "dependencies": {
          "MongoDB.Driver": "2.6.1",
          "MongoDB.Driver.Core": "2.6.1",
          "MongoDB.Bson": "2.6.1",
      "SharpZipLib": "0.86.0",
      "RabbitMQ.CLient": "5.0.1"
        }
      }
     }
  }

Below is the code for the packages i'm trying to use in my csx file...

#r "Newtonsoft.Json"
#r "Microsoft.ServiceBus"

using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ServiceBus.Messaging; --> ERROR
using Newtonsoft.Json; --> ERROR
using MongoDB.Driver; --> ERROR
using MongoDB.Bson; --> ERROR
using MongoDB.Bson.IO; --> ERROR
using RabbitMQ.Client; --> ERROR
using ICSharpCode.SharpZipLib.Zip.Compression.Streams; --> ERROR
hfires
  • 113
  • 10

0 Answers0