LocalDB using the Azure App service

I have a connection string below in a web configuration and works fine in Visual Studio.

<connectionStrings>
   <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-MyPortal-20170627104450.mdf;Initial Catalog=aspnet-MyPortal-20170627104450;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>

I tried porting an ASP.NET MVC application to Azure using Azure App and Azure AD. I changed the AttachDbFilename attribute below

AttachDbFilename=\App_Data\aspnet-MyPortal-20170620051631.mdf

I get below error:

Invalid value for the key 'attachdbfilename'.
Description: An unhandled exception occurred during the execution of the current web request. View the stack trace for more information about the error and its occurrence in the code.
Exception Details: System.ArgumentException: Invalid value for the key 'attachdbfilename'.
Source Error:
An unhandled exception was thrown during the execution of the current web request. Information about the origin and location of the exception can be identified using the exception stack trace below.

The application data folder contains the mdf file. How can I reference the connection string in web configuration?

- - Azure, Azure AD?

+4
2

, LocalDB Azure App Service.

- localdb Visual Studio - Azure?

0

. Webconfig, . AttachDBFilename Azure DB.

<add name="DefaultConnection" connectionString="Server = tcp:myserverazure2017.database.windows.net,1433; Initial Catalog = MyDBPro; Persist Security Info = False; User ID = ****; Password = ****; MultipleActiveResultSets = False; Encrypt = True; TrustServerCertificate = False; Connection Timeout = 30;" providerName="System.Data.SqlClient" />

0

Source: https://habr.com/ru/post/1680471/


All Articles