1
votes

I created one console for sending message to Azure Service bus topic and created to one service bus topic trigger. In locally it's working fine, but the same code is not working after deploy the same function in azure. I am new for Azure, Please help to solve the issue and take my code details below.

host.json

{
  "version": "2.0",
  "aggregator": {
    "batchSize": 1000,
    "flushTimeout": "00:00:30"
  },
  "extensions": {
    "cosmosDb": {},
    "durableTask": {},
    "eventHubs": {},
    "http": {},
    "queues": {},
    "sendGrid": {},
    "serviceBus": {}
  },
  "functions": [],
  "functionTimeout": "00:05:00",
  "healthMonitor": {
    "enabled": true,
    "healthCheckInterval": "00:00:10",
    "healthCheckWindow": "00:02:00",
    "healthCheckThreshold": 6,
    "counterThreshold": 0.80
  },
  "logging": {
    "fileLoggingMode": "debugOnly",
    "logLevel": {
      "Function.MyFunction": "Information",
      "default": "None"
    },
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "maxTelemetryItemsPerSecond": 5
      }
    }
  },
  "singleton": {
    "lockPeriod": "00:00:15",
    "listenerLockPeriod": "00:01:00",
    "listenerLockRecoveryPollingInterval": "00:01:00",
    "lockAcquisitionTimeout": "00:01:00",
    "lockAcquisitionPollingInterval": "00:00:03"
  },
  "watchDirectories": [ "Shared", "Test" ]
}

local.setting.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;....",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "MyConnection": "Endpoint=sb://...."
  }
}

tried another one

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "MyConnection": "Endpoint=sb://",
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "AzureWebJobsDashboard": "UseDevelopmentStorage=true"
  },
  "Host": {
    "LocalHttpPort": 7077
  }
}

Function code:

 [FunctionName("Function1")]
    public static void Run([ServiceBusTrigger("*****", "*****", Connection = "MyConnection")]string mySbMsg, ILogger log)
    {
        log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
    }

MyConnection--> Passing the service bus connection string here.

In local we can get the debug point, If we try with run the same function alone in another server it's not listening the request. Where I did the mistake? help me to solve this issue!

Update As well as, while publish the Azure bus click the application setting in visual studio. Then you need to give the connection string to remote also. Then surely it will work!

2
You do not have permission to save data on the server c drive. All data must be saved on the client file system which the users have permission to write.jdweng
Where I need to give the permission @jdwengRama Krishnan
You never want to save data on the server. The data always goes on the client (user) file system.jdweng

2 Answers

2
votes

Make sure you have put MyConnection in Application settings on Azure portal(Platform features> Application settings> Application settings section), local.settings.json is not published to Azure.

And I suggest removing other settings except "version": "2.0" in host.json. The content is a sample to explicate the structure of host.json, we don't need them all, just specify what you need.

2
votes

Your local.settings.json file would have these 3 values (plus others) ...

"SvcBusConStr": "Endpoint=sb://myservicebus Con String",
"SvcBusTopicName": "my-topic-name",
"SvcBusSubscriptionName": "my-sub-name",

Your Application Configuration Screen Page in Azure would need these 3 entries

SvcBusConStr  Endpoint=sb://myservicebus Con String
SvcBusTopicName   my-topic-name
SvcBusSubscriptionName   my-sub-name

Notice the Percent signs on the first two parameters to read the Application Environment settings. I also added the explicit listen only right.

 [FunctionName("Function1")]
    public static void Run([ServiceBusTrigger("%SvcBusTopicName%", "%SvcBusSubscriptionName%", AccessRights.Listen, Connection = "SvcBusConStr")]string mySbMsg, ILogger log)
    {
        log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
    }

My answer may not cover Azure Functions 2.0 perfectly.