Description
Check for a solution in the Azure portal
For issues in production, please check for a solution to common issues in the Azure portal before opening a bug. In the Azure portal, navigate to your function app => Platform features
=> Diagnose and solve problems
and the relevant dashboards before opening your issue.
Investigative information
Please provide the following:
- Timestamp:12:00 PM MDT - 12:10 MDT
- Function App version (1.0 or 2.0):3.x
- Function App name:PCFLNiceInContactWebHooks
- Function name(s) (as appropriate):CNAME
- Invocation ID:
- Region:Central US
Repro steps
Provide the steps required to reproduce the problem:
Expected behavior
EF Core should be able to query the database using linq
Actual behavior
Microsoft.Data.SqlClient throws an exception
2019-11-16T07:06:20.148 [Error] Executed 'LOG' (Failed, Id=cc946440-ea9e-4234-9143-0eb25dc47069)Invalid cast from 'System.String' to 'NiceInContactConfiguration.CallStatus'.
2019-11-16T07:06:20.157 [Error] Executed 'LOG' (Failed, Id=a81d4efa-ff12-4842-ada3-fc08d495210b)Invalid cast from 'System.String' to 'NiceInContactConfiguration.CallStatus'.
2019-11-16T07:06:20.152 [Error] System.PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform.at Microsoft.Data.SqlClient.SqlConnection..ctor(String connectionString)at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.CreateDbConnection()at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection()at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.CreateCommand(RelationalCommandParameterObject parameterObject, Guid commandId, DbCommandMethod commandMethod)at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.QueryingEnumerable1.Enumerator.MoveNext()at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable
1 source)at lambda_method(Closure , QueryContext )at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable1 source)at PCFL.NiceInContact.WebHooks.Webhooks.CNAME(HttpRequest req, ILogger log) in C:\Users\ialastairhunter\source\repos\PCFL.NiceInContact.WebHooks\PCFL.NiceInContact.WebHooks\Webhooks.cs:line 64 2019-11-16T07:06:20.155 [Error] System.PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform.at Microsoft.Data.SqlClient.SqlConnection..ctor(String connectionString)at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.CreateDbConnection()at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection()at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.CreateCommand(RelationalCommandParameterObject parameterObject, Guid commandId, DbCommandMethod commandMethod)at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.QueryingEnumerable
1.Enumerator.MoveNext()at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source)at lambda_method(Closure , QueryContext )at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable
1 source)at PCFL.NiceInContact.WebHooks.Webhooks.CNAME(HttpRequest req, ILogger log) in C:\Users\ialastairhunter\source\repos\PCFL.NiceInContact.WebHooks\PCFL.NiceInContact.WebHooks\Webhooks.cs:line 64
Known workarounds
None Know at this time
Related information
.net core 3.x
Dependancy injection
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AzureFunctionsVersion>v3-preview</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.10" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.0-preview1" />
<PackageReference Include="PCFL.EntityFramework.DataContext" Version="1.0.0.142" />
<PackageReference Include="PCFL.PestRoutes.Client" Version="1.0.0.141" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PCFL.EntityFramework.DataContext;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using RestRoutes.API;
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.Options;
using Microsoft.AspNetCore.Mvc.Formatters.Json.Internal;
using Microsoft.AspNetCore.Mvc;
[assembly: FunctionsStartup(typeof(PCFL.NiceInContact.WebHooks.Startup))]
namespace PCFL.NiceInContact.WebHooks
{
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddSingleton<PestRoutesCredentials>(s =>
new PestRoutesCredentials(s.GetService<IConfiguration>()["PestRoutesHost"],
s.GetService<IConfiguration>()["PestRoutesToken"],
s.GetService<IConfiguration>()["PestRoutesKey"]
));
builder.Services.AddSingleton<PestRoutesAPI>(s => new PestRoutesAPI(s.GetService<PestRoutesCredentials>()));
builder.Services.AddDbContext<EtlContext>((s, options) => options/*.UseLazyLoadingProxies()*/.UseSqlServer(s.GetService<IConfiguration>().GetConnectionString("PestRoutesContext"), op => op.EnableRetryOnFailure()), ServiceLifetime.Transient);
}
}
}