I made an azure web app. When I go to my web app URL it says the app is up and running, https://nameofmyapp.azurewebsites.net/.
When I try to go send a request for the web API by going to https://nameofmyapp.azurewebsites.net/api/Menus to get JSON text I receive this error
{
"Message": "An error has occurred.",
"ExceptionMessage": "The connection string 'PetSchedulerDbContext' in the application's configuration file does not contain the required providerName attribute.\"",
"ExceptionType": "System.InvalidOperationException",
"StackTrace": " at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)\r\n
Here is my connection string:
<connectionStrings>
<add name="PetschedulerDbContext" connectionString="Server=tcp:petschedulerserver.database.windows.net,1433;Initial Catalog=petschedulerdb;Persist Security Info=False;User ID=Julia;Password=Network5!;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" providerName="System.Data.SqlClient" />
</connectionStrings>
I have tried changing the provider name to
providerName="System.Data.EntityClient"
with the same result. I don't understand what the required provider name would be? Please let me know if you need more information.
Here are my cents for this issue:
Prerequisite: Please make sure you have the same set of connection string value in the Azure portal Web app configuration setting as well.
If you are using designed based approach, then you need to define the connections string that the designer generates and which looks something like this:
<add name="Northwind_Entities"
connectionString="metadata=res://*/Northwind.csdl|
res://*/Northwind.ssdl|
res://*/Northwind.msl;
provider=System.Data.SqlClient;
provider connection string=
"Data Source=.\sqlexpress;
Initial Catalog=Northwind;
Integrated Security=True;
MultipleActiveResultSets=True""
providerName="System.Data.EntityClient"/>
If you're not using the designer (if you don't have an .edmx file), the connection string should look like this:
<add name="ConnectionStringName" providerName="System.Data.SqlClient" connectionString="Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=False;User Id=userid;Password=password;MultipleActiveResultSets=True" />
Additional reference:
https://learn.microsoft.com/en-us/ef/ef6/fundamentals/configuring/connection-strings?redirectedfrom=MSDN
https://forums.asp.net/t/1858681.aspx?The+connection+string+EFDbContext+in+the+application+s+configuration+file+does+not+contain+the+required+providerName+attribute+
Hope it helps.
Related
I need to configure passwords to be fetched from Azure KeyVault in Azure Web App connection string. Can someone explain how to configure it ?
Thanks in advance !
I tried to get the passwords from key vault in Application settings and it worked fine , but couldn't able to integrate it in connection string.
Create an Azure KeyVault.
Create Secret. Copy the Secret Identifier of the Secret (this has to be used in Azure Configuration Connection String).
Provide necessary grants by using Access policies.
In Azure App Service => Configuration => Application Settings => Connection Strings, add the new Connection string setting.
For .NET Core App, the key name has to be MyNewConn.
For .NET Framework App, the name in the Azure App Connection String must be same as the key name in Local Configuration.
Thanks #Anand Sowmithiran for the Comment.
The value of the Connection string has to be #Microsoft.KeyVault(SecretUri=Secret Identifier).
Replace the Secret Identifier value with the value which we have copied from the KeyVault Secret (In Step 1).
For .NET Core Web App
appsettings.json
"ConnectionStrings": {
"MyNewConn": "LocalValue"
}
string connectionString = configuration.GetConnectionString("MyNewConn");
For .NET Framework Web App
In Web.config file, you must have the below settings
<configSections>
<section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=*****" restartOnExternalChanges="false" requirePermission="false" />
</configSections>
<configBuilders>
<builders>
<add name="AzureKeyVault" vaultName="KeyVaultName" type="Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Azure, Version=1.0.0.0, Culture=neutral" vaultUri="https://YourKeyVaultName.vault.azure.net" />
</builders>
</configBuilders>
<connectionStrings>
<add name="MyNewConn" connectionString="Retrieves the value from Azure App Service Connection String" providerName="System.Data.SqlClient" />
</connectionStrings>
var conn = ConfigurationManager.ConnectionStrings["MyNewConn"];
Update
In Azure Key Vault, the step where we create the Secret, add the Secret value as the connection string.
.
Rest other steps are same.
I have an Azure Web App (https://www.triviaweb.net/) and a connection string in the web.config that looks like this.
<connectionStrings>
<add name="Entities" connectionString="metadata=res://*/TriviaWebModel.csdl|res://*/TriviaWebModel.ssdl|res://*/TriviaWebModel.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:dolaris.database.windows.net;initial catalog={cata};persist security info=True;user id={usr};password={psw};multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
When I publish the web app using Visual Studio 2019 version 16.7.2 to Azure the web.config is transformed to this.
<connectionStrings>
<add name="Entities" connectionString="metadata=res://*/TriviaWebModel.csdl|res://*/TriviaWebModel.ssdl|res://*/TriviaWebModel.msl;provider=System.Data.SqlClient;provider connection string='metadata=res://*/TriviaWebModel.csdl|res://*/TriviaWebModel.ssdl|res://*/TriviaWebModel.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:dolaris.database.windows.net;initial catalog={cata};persist security info=True;user id={usr};password={psw};MultipleActiveResultSets=True;App=EntityFramework"'" providerName="System.Data.EntityClient" />
</connectionStrings>
It looks like the transformation kind of put a connection string inside the connection string. I can fix this manually on the server to make my app work but would much prefer that the publishing works correctly.
I’ve never seen anything like this.
Provider Connection String contains valid keyword/value pairs for the data provider. An invalid Provider Connection String will cause a run-time error when it is evaluated by the data source.
Make sure to escape the value according to the general syntax of ADO.NET connection strings. Consider for example the following connection string: Server=serverName; User ID = userID. It must be escaped because it contains a semicolon. Since it does not contain double quotation marks, they may be used for escaping:
Provider Connection String ="Server=serverName; User ID = userID";
Try changing your connection string from :
<add
name="Entities"
connectionString="metadata=res://*/TriviaWebModel.csdl|res://*/TriviaWebModel.ssdl|res://*/TriviaWebModel.msl;
provider=System.Data.SqlClient;
provider connection string="
data source=tcp:dolaris.database.windows.net;
initial catalog={cata};
persist security info=True;
user id={usr};
password={psw};
multipleactiveresultsets=True;
application name=EntityFramework""
providerName="System.Data.EntityClient" />
to:
<add
name="Entities"
connectionString="metadata=res://*/TriviaWebModel.csdl|res://*/TriviaWebModel.ssdl|res://*/TriviaWebModel.msl;"
provider= "System.Data.SqlClient"
providerConnectionString="data source=tcp:dolaris.database.windows.net;
initial catalog={cata};
persist security info=True;
user id={usr};
password={psw};
multipleactiveresultsets=True;
application name=EntityFramework;"
providerName="System.Data.EntityClient" />
For more information, you can visit Connection Strings in the ADO.NET Entity Framework.
I just start to learn new Office 365 API. I'm also not so deep understand server-side programming. I have VS2013 and all pre-requisites as pointed in the link bellow. Some example with Windows Desktop App worked. But when I get example https://code.msdn.microsoft.com/Office-365-APIs-Get-d75d1c8a - it fails during setting up in Service Manager after Sign-In to O365.
The error message - "Unsupported or invalid query filter clause specified for property '' appId of resource 'Service Principal' ". This message appear instead permissions in Service Manager. When I press OK - "Sign In" point in Service Manager still there - Authentication Failed.
Please help!
You need to remove the existing client id and settings from app.config (or web.config in web project). When I removed the following from App.config in the Office365Api.Demo project, I was able to register the app in my own Azure AD.
<add key="ida:ClientId" value="[put here your ClientID]" />
<add key="ida:RedirectUri" value="http://localhost/eb2c041088c22f67fecaffda29528308" />
<add key="ida:AuthorizationUri" value="https://login.windows.net/" />
I have the following issue when using BizTalk 2013 ("R1") and SharePoint Online:
I have a static send port configured to add data to one specific list in a list in a SharePoint Online environment.
I have authentication setup using the username and password and I'm 100% sure this is a correct username and password. I'm able to login using the same credentials via a browser without problem.
FYI: the account used is a "Microsoft" only account, so not listed as an organizational (work/school) account as well.
Whenever I try to send something to the list, I get the following error:
A message sent to adapter "Windows SharePoint Services" on send port "SP_SharePointOnline" with URI "wsss://company.sharepoint.com:443/sites/poc/Biztalk-Demo/TR/Lists/List%%201" is suspended.
Error details: [System.ServiceModel.CommunicationObjectFaultedException] The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
This error was triggered by the Windows SharePoint Services receive location or send port with URI wsss://company.sharepoint.com:443/sites/poc/Biztalk-Demo/TR/Lists/List%%201.
Windows SharePoint Services adapter event ID: 12310
I have enabled WCF and WIF tracing in the BizTalk BTSNTSvc.exe and BTSNTSvc.exe.config as follows:
<system.diagnostics>
<sources>
<source name="Microsoft.IdentityModel" switchValue="Verbose">
<listeners>
<add name="wif" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
<listeners>
<add name="wcf" />
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="C:\logs\WCF64.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="wcf" />
<add initializeData="C:\logs\WIF64.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="wif" />
</sharedListeners>
I get WCF logging, but I don't have any WIF logging (as I would expect).
The WCF logging provided the following as to why the channel faults (extract from WCF Trace Viewer):
<S:Fault>
<S:Code>
<S:Value>S:Sender</S:Value>
<S:Subcode>
<S:Value>wst:FailedAuthentication</S:Value>
</S:Subcode>
</S:Code>
<S:Reason>
<S:Text xml:lang="en-US">Authentication Failure</S:Text>
</S:Reason>
<S:Detail>
<psf:error>
<psf:value>0x80048821</psf:value>
<psf:internalerror>
<psf:code>0x80041012</psf:code>
<psf:text>The entered and stored passwords do not match.
</psf:text>
</psf:internalerror>
</psf:error>
</S:Detail>
</S:Fault>
As said: I'm 100% sure this is the correct username and password!
I'm stuck here, anyone able to help me out or point me in the right direction?
Why don't I have any WIF logging?
Regards,
I think there is a problem in your URL. what if you try to use in the utl the link to your sharepoint site and the name of your List as "Destination Folder URL".
you can check this walkthrough
I have a console application which connects to two different SQL databases. I'm using the "impersonate" tag within the config file to force the application to login as "APP_USER". The APP_USER account utilizes windows authentication & has been granted permissions in both databases.
The first DB connection works fine, but the second one fails as it is trying to log in as my account which does not have access.
System.Data.SqlClient.SqlException: Login failed for user 'DOMAIN\CURRENT_USER'.
What do I need to change in my config to make the application login to both databases as another user?
<configuration>
<connectionStrings>
<add name="Connection1" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=DB1;initial catalog=DBcat1;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="Connection2" connectionString="metadata=res://*/Models.Model2.csdl|res://*/Models.Model2.ssdl|res://*/Models.Model2.msl;provider=System.Data.SqlClient;provider connection string="data source=DB2;initial catalog=DBcat2;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
<identity impersonate="true" userName="DOMAIN\APP_USER" password="password"/>
</system.web>
</configuration>
Apparently the config-setting route can only be used in asp.net projects. In order to accomplish this within a console application, you have to write code that utilizes LogonUser within the advapi32.dll library.
Similar question: StackOverflow: Windows Impersonation from C#
I based my final code off of the following project: Code Project: A small C# Class for impersonating a User
Everything seems to be working fine now.