2

I need to get a Dropbox folder / one drive watch , and any file update or change gets FTP'd to output. To get familiar with I tried C# code shared by

but I get the following error message :- Process a file using Azure Function ======Update C# code that I have used ======

My run.csx is as below: using System;

public static void Run(string input, out string output, TraceWriter log)
{
    log.Info($"C# SaaS trigger function processed a file!!");

output = input;
}

==========================

My function.json is as below :

{
  "bindings": [
{
  "type": "apiHubFileTrigger",
  "name": "input",
  "direction": "in",
  "path": "/Docs/{name}",
  "connection": "dropbox_DROPBOX"
},
{
  "type": "apiHubFile",
  "name": "output",
  "direction": "out",
  "path": "{name}",
  "connection": "googledrive_GOOGLEDRIVE"
}
  ],
"disabled": false
    }

where paths are modified because I was getting the below error:

Host Error: Microsoft.Azure.WebJobs.Extensions.ApiHub: Path 'input-cs' is invalid. IFolderItem.RootPath must be set to a valid directory location.

I played around, and removed the 'input-cs' and 'output-cs' in my function.json above,the above error goes away and compilation is succeeding but again in logs I dont find it proper. Log is as below:

2016-07-25T12:52:07.957 Script for function 'SaasFileTriggerCSharp1' changed. Reloading.

2016-07-25T12:52:07.957 Compiling function script.

2016-07-25T12:52:08.020 Compilation succeeded.

2016-07-25T12:52:29.137 Exception while executing function: Functions.SaasFileTriggerCSharp1. Microsoft.Azure.WebJobs.Host: One or more errors occurred. Exception binding parameter 'input'. Microsoft.Azure.ApiHub.Sdk: /apim/dropbox/8b82684e13e44f499752a742adc4d30d/datasets/default/GetFileContentByPath?path=%7B%0A%20%20%20%20%22name%22:%20%22IMG-20140517-WA0001.jpg%22%0A%7D.

Tried with C# and Node.js Saasfiletriggers and same exception. Below are the invocation log:

==================================================================== Failure: Exception binding parameter 'input'

input : /apim/dropbox/8b82684e13e44f499752a742adc4d30d/datasets/default/GetFileContentByPath?path=%7B%0A%20%22name%22%20:%20%22%22%0A%7D

ilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.Azure.WebJobs.Extensions.ApiHub.Common.GenericFileBinding2.<BindAsync>d__11.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.WebJobs.Extensions.ApiHub.Common.GenericFileTriggerBindingProvider2.GenericTriggerbinding.d__9.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.WebJobs.Host.Triggers.TriggeredFunctionBinding`1.d__7.MoveNext() --- End of inner exception stack trace --- at Microsoft.Azure.WebJobs.Host.Executors.DelayedException.Throw() at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.d__33.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.d__2e.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.d__15.MoveNext() --- End of inner exception stack trace ---

====================================================================

Would there be any samples I could read or refer to adapt for my needs. Request suggestions and help.

Community
  • 1
  • 1
H Bala
  • 1,271
  • 2
  • 14
  • 28

1 Answers1

0

If you want to write to the root folder of googledrive the path should be "/{name}" with forward slash.

In the example below the output folder is 'docsoutput'. if the output folder does not exist it will be created when the function runs.

If the example below doesn't work for you, please paste your C# function code as well. also make sure you are using the latest version of functions runtime.

using System;

public static void Run(string input, out string output, TraceWriter log)
{
    log.Info($"C# SaaS trigger function processed a file!!");

    output = input;
}

function.json:

   {
      "bindings": [
    {
      "type": "apiHubFileTrigger",
      "name": "input",
      "direction": "in",
      "path": "Docs/{name}",
      "connection": "dropbox_DROPBOX"
    },
    {
      "type": "apiHubFile",
      "name": "output",
      "direction": "out",
      "path": "docsoutput/{name}",
      "connection": "googledrive_GOOGLEDRIVE"
    }
      ],
    "disabled": false
    }
  • Thanks for the reply. Today I was prompted to update function runtime from 0.3 to 0.4 and now **version is 0.4**. Now, get the following error : `input /apim/dropbox/4c60dc53f902472fb59704d1f0dc7f2f/datasets/default/GetFileContentByPath?path=%7B%0A%22name%22%20:%20%22FB_IMG_1468342110321.jpg%22%20%0A%7D output No value for named parameter 'name'.` – H Bala Jul 27 '16 at 06:47
  • Also, I played around with logic app designer to know the dropbox connection and code. Interestingly, the folder of name "Docs" is coming in template as "docs". Please find my main post updated with code as well. – H Bala Jul 27 '16 at 06:52
  • Ok, looks like in the above scenario you are clicking on the 'Run' button in the portal rather than actually copying a file to the 'docs' folder of your dropbox and have the function trigger copy the file over. In order for the 'Run' scenario to work you will need to have something like this in the request body box: docs/readme.md (assuming you have a file named readme.md) looks like there is a bug in the template which copies the json content in that box by default. we will fix it soon. – Henry Hamid Safi - MSFT Jul 27 '16 at 17:08
  • So instead of having the default: { "name": "input-cs/{your file}" } just replace the entire content with input-cs/{your file} (where input-cs is your trigger folder, in your example will be docs and {your file} is an existing file on that folder. like docs/readme.md. you can also always directly copy a file in your dropbox folder and have the function trigger automatically executed. – Henry Hamid Safi - MSFT Jul 27 '16 at 17:19