question

DominikFRemshardt-3039 avatar image
0 Votes"
DominikFRemshardt-3039 asked DominikFRemshardt-3039 published

azure function with twilio won't work

I'm trying to deploy a function I found on YT but I fail to compile the function with this error msg:

run.csx(7,7): error CS0246: The type or namespace name 'Twilio' could not be found (are you missing a using directive or an assembly reference?)

My function cotains following project.json

{
"frameworks": {
"net46": {
"dependencies": {
//"Twilio.Twiml": "3.5.0"
"Twilio": "5.0.2"
}
}
}
}

and the run.csx starts with:

r "System.Runtime"


using System.Net;
using System.Text;
using Twilio;
using Twilio.TwiML;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;


The funtion is configured as: FUNCTIONS_EXTENSION_VERSION ~1

Any suggestions on how to make things work?

azure-functions
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MayankBargali-MSFT avatar image
1 Vote"
MayankBargali-MSFT answered MayankBargali-MSFT edited

@DominikFRemshardt-3039 As you are using function app version 1.x please refer to this document how to install the package that provides the Twilio bindings.
I will recommend you to use the function app 3.x and follow function binding twilio that covers the attributes/bindings and the example for usage.

As per the error message looks like the Twilio namespace was not found on your project i.e. the package was not installed correctly.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DominikFRemshardt-3039 avatar image
0 Votes"
DominikFRemshardt-3039 answered DominikFRemshardt-3039 published

I tried using VV.1, 2 and 3 and none of them works

I keep getting the same error:

2021-10-20T10:25:23.987 [Information] Compilation failed.
2021-10-20T10:25:34.922 [Information] Executing 'Functions.Twilio' (Reason='This function was programmatically called via the host APIs.', Id=0c2dd7fa-835a-49c2-9504-7769b4786e00)
2021-10-20T10:25:34.923 [Information] Package references have been updated.
2021-10-20T10:25:34.924 [Information] Restoring packages.
2021-10-20T10:25:34.951 [Information] Starting packages restore
2021-10-20T10:25:36.075 [Information] C:\local\Temp\403c3d8b-c369-4941-ba36-9ea44ce28b07\function.proj(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.
2021-10-20T10:25:36.148 [Information] Packages restored.
2021-10-20T10:25:36.261 [Warning] You may be referencing NuGet packages incorrectly. The file 'C:\home\site\wwwroot\Twilio\project.json' should not be used to reference NuGet packages. Try creating a 'function.proj' file instead. Learn more: https://go.microsoft.com/fwlink/?linkid=2091419
2021-10-20T10:25:36.261 [Warning] You may be referencing NuGet packages incorrectly. The file 'C:\home\site\wwwroot\Twilio\project.json' should not be used to reference NuGet packages. Try creating a 'function.proj' file instead. Learn more: https://go.microsoft.com/fwlink/?linkid=2091419
2021-10-20T10:25:36.261 [Warning] You may be referencing NuGet packages incorrectly. The file 'C:\home\site\wwwroot\Twilio\project.json' should not be used to reference NuGet packages. Try creating a 'function.proj' file instead. Learn more: https://go.microsoft.com/fwlink/?linkid=2091419
2021-10-20T10:25:36.262 [Warning] You may be referencing NuGet packages incorrectly. The file 'C:\home\site\wwwroot\Twilio\project.json' should not be used to reference NuGet packages. Try creating a 'function.proj' file instead. Learn more: https://go.microsoft.com/fwlink/?linkid=2091419
2021-10-20T10:25:36.262 [Warning] You may be referencing NuGet packages incorrectly. The file 'C:\home\site\wwwroot\Twilio\project.json' should not be used to reference NuGet packages. Try creating a 'function.proj' file instead. Learn more: https://go.microsoft.com/fwlink/?linkid=2091419
2021-10-20T10:25:36.263 [Warning] You may be referencing NuGet packages incorrectly. The file 'C:\home\site\wwwroot\Twilio\project.json' should not be used to reference NuGet packages. Try creating a 'function.proj' file instead. Learn more: https://go.microsoft.com/fwlink/?linkid=2091419
2021-10-20T10:25:36.289 [Error] Function compilation errorMicrosoft.CodeAnalysis.Scripting.CompilationErrorException : Script compilation failed.at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.CreateFunctionTarget(CancellationToken cancellationToken) at D:\a\1\s\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 321at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async Microsoft.Azure.WebJobs.Script.Description.FunctionLoader`1.GetFunctionTargetAsync[T](Int32 attemptCount) at D:\a\1\s\src\WebJobs.Script\Description\FunctionLoader.cs : 55at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.GetFunctionTargetAsync(Boolean isInvocation) at D:\a\1\s\src\WebJobs.Script\Description\DotNet\DotNetFunctionInvoker.cs : 193
2021-10-20T10:25:36.351 [Error] run.csx(3,1): error CS0006: Metadata file 'Twilio' could not be found
2021-10-20T10:25:36.409 [Error] run.csx(4,1): error CS0006: Metadata file 'Microsoft.Azure.WebJobs.Extensions.Twilio' could not be found
2021-10-20T10:25:36.460 [Error] run.csx(9,7): error CS0246: The type or namespace name 'Twilio' could not be found (are you missing a using directive or an assembly reference?)
2021-10-20T10:25:36.508 [Error] run.csx(10,7): error CS0246: The type or namespace name 'Twilio' could not be found (are you missing a using

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.