Hello i have been searching everywhere for a solution to log to the database using NLog on Identity Server v3, so far i cannot get very far. It seems Identity Server works with many different Loggers. Does this require an NLog.config file?
Related
I am completely noob to Azure. When I try to publish .net core app on Azure. its published and interface is showing, but it seems like database is not working i am unable to submit form data. in console it gives 500 error. here is the link:
Azure site link
There are a few steps that you can follow to solve this.
Check your appsettings.json - Check whether you have put the connection string in your appsettings.json
Validate the connection string - This might be a result of a wrong connection string. You can get the correct connection string from the Azure Database. It's something similar to this (Server=tcp:mssql-care-dev.database.windows.net,1433;Initial Catalog=sqldb-care-dev;Persist Security Info=False;User ID=MsSqlAdmin;Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;)
Replace {your_password} with your actual password. And the SQL server name.
Add a debug point in your application. And then run the local application against the hosted database. This will give you an insight into what's happening.
I am following the instructions at https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-connect-msi to transition from username/password connection strings to authenticate using MSI. The application runs fine and authenticates to the SQL server both for local development and when running deployed on Azure App Service.
However, now when I try and add/get migrations via the Package Manager Console it no longer works.
Get-Migrations now produces:
No migrations have been applied to the target database.
I tried switching back to my old username/password based connection string and I still get the same output. However, if I comment out the section of web.config that registers the SqlAuthenticationProviders:
<SqlAuthenticationProviders>
<providers>
<add name="Active Directory Interactive" type="Microsoft.Azure.Services.AppAuthentication.SqlAppAuthenticationProvider, Microsoft.Azure.Services.AppAuthentication" />
</providers>
</SqlAuthenticationProviders>
Then Get-Migrations starts working fine with my old connection string. How can I have this authentication provider configured and allow "Add-Migration" and "Get-Migrations" tools to work?
Entity Framework 6.4.4 with code first migrations
.NET Framework 4.7.2
ASP.net MVC
Thanks
The problem ended up being twofold:
We had the EF context in a separate project from the web project. I had to add the Microsoft.Azure.Services.AppAuthentication package and config changes to enable the SQL authentication provider to the project containing the context and migrations.
After resolving (1), username/password connection strings would work again even with the auth provider registered however Azure AD token authentication still didn't work with the EF package manager console tools. This ended up being due to a dll (Microsoft.IdentityModel.Clients.ActiveDirectory) failing to load due to a version mismatch. I made both projects use the same version of this package and corrected binding redirects and then AD authentication worked.
The key was that Get-Migrations did not provide any error output - it just said there were no migrations. However, running Update-Database was much more enlightening as it actually provided an exception that indicated what was failing in the authentication.
I believe the issue revolves around the fact that the application was working correctly based on the web application projects packages/configuration whereas it appears the EF cli tools were using the other projects DLL directly, with the web.config from the web project, which opened it up to inconsistency.
I have a nodejs app which is nothing but a BOT built using Microsoft's bot builder framework. I created an azure app service to host this app. I would like to find a way to persist all the application logs and web server logs as well (if possible) to some persistent store. Just like native web applications where we can look up logs on a app server & debug the application issues.
After doing some research I found official document from microsoft on this but looks like it has following limitations.
We can't use file storage option of app service as it's good for 12
hours only so logs will not be saved forever.
Currently only .NET application logs can be written to the blob
storage. Java, PHP, Node.js, Python application logs can only be
stored on the file system (without code modifications to write logs
to external storage).
I would like to check if anyone has tried any different approach for nodejs app. If yes then please share.
Thank you.
So I would respond by saying that this is not really a Bot specific problem... meaning you would have the same problem if you were writing a vanilla Web API and wanted to have persistent logs. You need to pick on a logging technology that let's you log to a more persistent store than just the file system.
Since you're using Node you might want to look at leveraging the Winston logging framework which has an abstraction for various transports to be plugged in. Then you would plug in the Azure Storage Blob Transport when running in production and that will ensure that your logs are written out to Azure Storage.
Still, you'd have to go collect those from Azure Storage and aggregate them yourself which can be painful. If you really want real-time a distributed tracing system though, you might want to look into using Application Insights instead. There's even a Winston transport for that as well if you want to stay abstracted from using AI directly and just use it as another log stream.
I am experimenting with EF7 beta 4 in combination with Azure web apps. Strangely:
1. A local web server / local db setup works;
2. A local web server / azure db setup works;
3. But: the Azure web server with azure db setup does not work. This results in the following infamous exception:
InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
The connectionstring I use is as follows (currently the same on local web server and Azure web server):
Server=...database.windows.net,1433;Database=...;User ID=...;Password=...;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;MultipleActiveResultSets=true
What do I have to do to get it running?
I had exactly the same problem when using Azure SQL Database.
My web.config files had the same flag in relevant connection strings. Everything worked fine locally but it didn't work when I published my solution into azure as web app.
MultipleActiveResultSets=true
The reason is that web.config files might be overwritten in your publishing profile. You need to add that setting explicitly like below:
Ok, I do not know why Elmah is not logging any errors while deployed on Windows Azure. Another thing is that it used to work before. The environment is the same.
using SqlErrorLog on Sql Azure
Sql Azure sharing the same database as the main site. I did not use a separate database so I can use the same connection string.
building off the source and I've excluded the VistaDB and SQLite dlls.
I've checked my web.config settings and have the handler and module defined under system.webServer. It seems to log messages alright under local development (webdev.exe) and the local sql express schema was exported to an sql azure schema (including the stored procs).
The only difference is that on the main site, the app is running under a main domain with multiple subdomains. Locally this is simulated by modifying the host file. Logs ok locally but not when deployed.
Any ideas on what I should do to find out what's wrong? Last option is using diagnostics to trace/find out what's wrong while it's deployed but that's a pita.
It turns out that the table Elmah_Error was created with a non-clustered primary key which is not supported by Sql Azure.
It seems that the SSMS 2008 R2 Nov CTP still exports nonclustered PK as nonclustered PKs even when you specify the target as SQL Azure. :(