Azure Functions issue?
See original GitHub issueI’m creating an Azure Function to act as a backend for an Alexa skill.
All I’ve done so far in Visual Studio:
- File -> New Azure Functions project
- Add new Azure Function
- Add AlexaSkillsKit.NET with NuGet
- Create a shell of a
Speechlet
implementation - Add the minimum code to the Azure Function to process the speechlet
When I compile, I get an error:
Could not load file or assembly ‘Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ or one of its dependencies. The system cannot find the file specified.
But according to NuGet in Visual Studio, it’s not trying to use 7.0.0.0, it’s using 9+. I’ve tried updating and downgrading the JSON.net package. I’ve tried Clean/Rebuild/restarting from scratch.
I thought that maybe assembly binding might be the answer, but there’s no Web.config or App.config in an Azure Functions project.
What am I missing? How do I get rid of this error?
Speechlet code:
public class MySpeechlet : SpeechletBase, ISpeechletWithContextAsync
{
public Task<SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session, Context context)
{
throw new System.NotImplementedException();
}
public Task<SpeechletResponse> OnLaunchAsync(LaunchRequest launchRequest, Session session, Context context)
{
throw new System.NotImplementedException();
}
public Task OnSessionStartedAsync(SessionStartedRequest sessionStartedRequest, Session session, Context context)
{
throw new System.NotImplementedException();
}
public Task OnSessionEndedAsync(SessionEndedRequest sessionEndedRequest, Session session, Context context)
{
throw new System.NotImplementedException();
}
}
Azure Function:
public static class MyFunction
{
[FunctionName("MyFunction")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
{
var speechlet = new MySpeechlet();
return await speechlet.GetResponseAsync(req);
}
}
I think this may be an issue with the Azure Functions SDK, but is there some way to workaround it?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (1 by maintainers)
Top GitHub Comments
Finally I had to deal with this error, as I was unable to publish my Function to Azure.
It seems to be a known issue in Azure function generator.
The solution is to mark your custom speechlet class as internal. Alternatively, you can move speechlet class to separate project as mentioned by @mgroves
Note: To make speechlet visible for unit tests project, add
AssemlyInfo.cs
to Function’sProperties
folder and put[assembly: InternalsVisibleTo("MySkill.UnitTests")]
attribute there.Can we close it, as it is more of Azure issue and there is not much we can do, apart from releasing .Net Core library version?