diff --git a/src/Microsoft.SqlTools.ServiceLayer/AzureFunctions/AddSqlBindingOperation.cs b/src/Microsoft.SqlTools.ServiceLayer/AzureFunctions/AddSqlBindingOperation.cs
index 25674745..7c7578af 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/AzureFunctions/AddSqlBindingOperation.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/AzureFunctions/AddSqlBindingOperation.cs
@@ -64,7 +64,7 @@ namespace Microsoft.SqlTools.ServiceLayer.AzureFunctions
}
MethodDeclarationSyntax azureFunction = matchingMethods.First();
- var newParam = this.Parameters.bindingType == BindingType.input ? this.GenerateInputBinding() : this.GenerateOutputBinding();
+ var newParam = this.Parameters.bindingType == BindingType.input ? this.GenerateInputBinding() : this.GenerateOutputBinding(azureFunction);
// Generate updated method with the new parameter
// normalizewhitespace gets rid of any newline whitespace in the leading trivia, so we add that back
@@ -128,8 +128,12 @@ namespace Microsoft.SqlTools.ServiceLayer.AzureFunctions
///
/// Generates a parameter for the sql output binding that looks like
/// [Sql("[dbo].[table1]", ConnectionStringSetting = "SqlConnectionString")] out Object output
+ /// if the Azure Function method is not async and
+ /// [Sql("[dbo].[table1]", ConnectionStringSetting = "SqlConnectionString")] IAsyncCollector
- private ParameterSyntax GenerateOutputBinding()
+ private ParameterSyntax GenerateOutputBinding(MethodDeclarationSyntax azureFunction)
{
// Create arguments for the Sql Output Binding attribute
var argumentList = SyntaxFactory.AttributeArgumentList();
@@ -140,9 +144,22 @@ namespace Microsoft.SqlTools.ServiceLayer.AzureFunctions
attributesList = attributesList.Add(SyntaxFactory.AttributeList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Attribute(SyntaxFactory.IdentifierName("Sql")).WithArgumentList(argumentList))));
var syntaxTokenList = new SyntaxTokenList();
- syntaxTokenList = syntaxTokenList.Add(SyntaxFactory.Token(SyntaxKind.OutKeyword));
+ TypeSyntax typeSyntax;
- ParameterSyntax newParam = SyntaxFactory.Parameter(attributesList, syntaxTokenList, SyntaxFactory.ParseTypeName(typeof(Object).Name), SyntaxFactory.Identifier("output"), null);
+ // Check if Azure Function method is async
+ IEnumerable asyncModifier = azureFunction.Modifiers.Where(m => m.ToString() == "async");
+ bool asyncMethod = asyncModifier.Count() > 0;
+ if (asyncMethod)
+ {
+ typeSyntax = SyntaxFactory.ParseTypeName("IAsyncCollector