Disable Entity Framework logging in Azure Function - entity-framework

I have an Azure Function in .net5 (a.k.a. dotnet-isolated) and I've added Entity Framework like this
services.AddDbContext<EfDbContext>(options =>
{
options.UseSqlServer(context.Configuration[...], builder =>
{
builder.EnableRetryOnFailure();
});
});
When I run the function I see the DB queries from EF in the console (info level judging by the color).
How can I disable them? I tried obvious options in my host.json:
"logging": {
"logLevel": {
"Microsoft.EntityFrameworkCore": "Warning",
}
}
and
"logging": {
"logLevel": {
"default": "Information",
"Microsoft.EntityFrameworkCore": "Warning",
"Microsoft.EntityFrameworkCore.Database": "Warning",
"Microsoft.EntityFrameworkCore.Query": "Warning"
}
}
or even
"logging": {
"logLevel": {
"Microsoft": "Warning",
}
}
but it didn't help. The only option which worked was
"logging": {
"logLevel": {
"default": "Warning",
}
}
Am I missing something?

Found a way. That's a bit strange though and I still wanna understand how it works and why it's done this way. Anyways, from AppInsights logs I found out that EF logs are written under the Function.<YOUR_FUNCTION_NAME>.User category. (turns out that a standard EF category is somehow overwritten by the functions runtime or so?).
That means that I can impact on the overall log level of a specific function by
"logging": {
"logLevel": {
"Function.MyFunc1.User": "Debug",
"Function.MyFunc2.User": "Warning"
}
}
in the host.json. It can be helpful but it doesn't solve my problem.
If however I now add a filter in the Program.cs like this:
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
...
.ConfigureLogging(builder =>
{
builder.AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Warning);
})
...
the EF info logs are gone.

This worked for me:
builder.AddFilter("Microsoft.EntityFrameworkCore", LogLevel.None);

Related

No handler found for URI (elasticsearch)

Im trying to add type to index like this:
PUT /catalog/_mapping/product
{
"properties": {
"name": {
"type":"text"
}
}
}
In answer I get an error:
{
"error" : "no handler found for uri [/catalog/_mapping/product?pretty=true] and method [PUT]"
}
The same situation in CURL. How I can fix it?
I assume you use ElasticSearch 8.x version.
From ElasticSearch 8.x version, only _doc is supported and it is just an endpoint name, not a document type. So try with:
PUT /catalog/_doc/product
{
"properties": {
"name": {
"type":"text"
}
}
}
There's no need to specify anything after _mapping since there can only be a single mapping type in an index mapping.
So simply like this will work:
PUT /catalog/_mapping
{
"properties": {
"name": {
"type":"text"
}
}
}

Amplify.Auth.signInWithWebUI is launching webview with empty HTTP URL

Problem
Amplify's signInWithWebUI is opening an webview for sign-in, but it opens with empty URL like you can see in the attached images at the bottom. I'm struggling to point out what configuration determines this signin URL. Any hint or help would be very appreciated. Thanks.
More context
I'm trying to implement Social signin with Google in my ios app. I already have AWS Cognito setup for Google signin that is working fine in my web app, so I've added amplify-ios package to my ios, configured and called signInWithWebUI function following these guides.
https://docs.amplify.aws/lib/auth/social_signin_web_ui/q/platform/ios/
https://docs.amplify.aws/lib/auth/existing-resources/q/platform/ios/
Here is how I'm calling the function and Amplify configuration file(amplifyconfiguration.json).
Amplify.Auth.signInWithWebUI(for: AuthProvider.google,
presentationAnchor: UIApplication.shared.windows.filter {$0.isKeyWindow}.first!
)
{
"auth": {
"plugins": {
"awsCognitoAuthPlugin": {
"IdentityManager": {
"Default": {}
},
"CognitoUserPool": {
"Default": {
"PoolId": "us-east-1_[REDACTED]",
"AppClientId": "[REDACTED]",
"Region": "us-east-1"
}
},
"Auth": {
"Default": {
"authenticationFlowType": "USER_SRP_AUTH",
"OAuth": {
"WebDomain": "https://[REDACTED].auth.us-east-1.amazoncognito.com",
"AppClientId": "[REDACTED]",
"SignInRedirectURI": "myapp://callback/",
"SignOutRedirectURI": "myapp://signout/",
"Scopes": [
"email",
"openid",
"profile",
"aws.cognito.signin.user.admin"
]
},
}
}
}
}
}
}
These are what the app shows when signInWithWebUI is called.
https://i.stack.imgur.com/tmbWB.png
https://i.stack.imgur.com/FnxbN.png
It turned out that WebDomain in the configuration file shouldn't include "https://" part. Now it looks like following and it loads Google's signin page properly.
{
"WebDomain": "[REDACTED].auth.us-east-1.amazoncognito.com"
}

Host ASP.NET Core Application on Raspbian with LocalDB

I am trying to host my Asp.Net Core application on a Raspberry Pi 4 with a LocalDB, but I get the following error message:
An unhandled exception occurred while processing the request.
PlatformNotSupportedException: LocalDB is not supported on this platform.
Microsoft.Data.SqlClient.SNI.LocalDB.GetLocalDBConnectionString(string localDbInstance)
This is how my appsettings.json looks like:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"MyString": "data source=(localdb)\\MSSQLLocalDB;initial catalog=MyDatabase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"
},
}
That's how I configure the Database in my Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<DatenbankKontext>(item =>
item.UseSqlServer(Configuration.GetConnectionString("MyString")));
}
It worked fine on Windows but I don't know how to properly configure it for Windows. How can I solve this?

How to avoid additional request for model data assigned to "dataSources"? (Component-preload.js)

I'm defining a JSON data source in my manifest.json as follows (only relevant parts shown):
{
"_version": "1.8.0",
"sap.app": {
"id": "myAppID",
"dataSources": {
"application_datasource": {
"uri": "/model/application.json",
"type": "JSON"
}
}
}
},
"sap.ui5": {
"models": {
"application": {
"type": "sap.ui.model.json.JSONModel",
"dataSource": "application_datasource"
}
}
}
This works quite well; the JSON is loaded from the webserver.
When using the UI5-Tooling to build the app, I can see that the /model/application.json is actually included in the Component-preload.js under the key "/myAppID/model/application.json".
When loading the application from the dist-folder, the app still hits the webserver for the /model/application.json and is not pulling it from the Component-preload.js.
What am I missing here to make it use the already in memory existing data? As far as I can see, the manifest.json itself is already pulled from the Component-preload.js.

Google Home dialogFlow V2 API mediaResponse not working

I decided to upgrade my Google Assistant action to use "dialogFlow V2 API" and my webhook returns an object like this
{
"fulfillmentText": "Testing",
"fulfillmentMessages": [
{
"text": {
"text": [
"fulfillmentMessages text attribute"
]
}
}
],
"payload": {
"google": {
"richResponse": {
"items": [
{
"mediaResponse": {
"mediaType": "AUDIO",
"mediaObjects": [
{
"name": "mediaResponse name",
"description": "mediaResponse description",
"largeImage": {
"url": "https://.../640x480.jpg"
},
"contentUrl": "https://.../20183832714.mp3"
}
]
},
"simpleResponse": {
"textToSpeech": "simpleResponse: testing",
"ssml": "simpleResponse: ssml",
"displayText": "simpleResponse displayText"
}
}
]
}
}
},
"source": "webhook-play-sample"
}
But I get an error message saying my action it is not available, is mediaResponse supported by V2?, should I format my object differently?, also, when I remove "mediaResponse" object works just fine and the assistant will speak the simpleResponse part.
This action was re-created this Mid March 2018 and I read about May deadline and that is why I decide to upgrade to V2, do you think I should go back to V1, I know I will have to delete it and re-created but that is fine. This is a link to the JSON object I see in the debug tab. Thanks once again
I set "API V2" in my action dialogFlow console, this is a screenshot of that setting
Here is an screenshoot of my action's integration -> Google Assistant
Thanks Allen, Yes I do have "expectUserResponse": false, I added the suggestion object you recommended but, unfortunately nothing changed, I am still getting this error
Simulator debug tag details
First of all - this is not a problem with Dialogflow V2. You also seem to be confusing the sunset of Actions on Google V1 with the release of Dialogflow V2 - they are two different creatures completely. If your project was using AoG V1, there would be a setting on the Actions integration screen, and thee isn't.
It is fine if you want to move to Dialogflow V2, but it isn't required. Media definitely works under Dialogflow V2.
The array of items must include a simpleResponse item first, before any of the other items in the RichResponse. (You also shouldn't include both ssml and textToSpeech - just one of them.) You also don't need the fulfillmentText and fulfillmentMessages components, since those are provided by the richResponse.
You also need to include suggestions chips unless you have set expectUserResponse to false. Somewhere in the simulator debug is probably a block that says
{
"name": "MalformedResponse",
"debugInfo": "expected_inputs[0].input_prompt.rich_initial_prompt: Suggestions must be provided if media_response is used..",
"subDebugEntryList": []
}
So something more like this should work:
{
"payload": {
"google": {
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "simpleResponse: testing",
"displayText": "simpleResponse displayText"
},
"mediaResponse": {
"mediaType": "AUDIO",
"mediaObjects": [
{
"name": "mediaResponse name",
"description": "mediaResponse description",
"largeImage": {
"url": "https://.../640x480.jpg"
},
"contentUrl": "https://.../20183832714.mp3"
}
]
}
}
]
"suggestions": [
{
"title": "This"
},
{
"title": "That"
}
]
}
}
},
"source": "webhook-play-sample"
}