2017-06-30 14 views
4

Web設定で以下の接続文字列があり、Visual Studioで正常に動作しています。Azureアプリケーションサービスで使用しているLocalDB

<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> 

Azure AppサービスとAzure ADを使用して、自分のASP.NET MVCアプリケーションをAzureに移植しようとしました。私は、エラーの下に取得していますAttachDbFilename=\App_Data\aspnet-MyPortal-20170620051631.mdf

以下のようにAttachDbFilename属性を変更:

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

のApp Dataフォルダは、MDFファイルが含まれていません。どのように私はWeb設定の接続文字列でそれを参照するのですか?

Azure WebアプリケーションがAzure ADで認証されるためのサンプルプログラムはありますか?

+0

あなたは '置き換えている理由の特定の理由がある|' App_Dataに\ 'で' | DataDirectoryの? – pijemcolu

答えて

0

簡単に言うと、Azure App ServiceではLocalDBを使用できません。

別の答えがある

からHow to connect a localdb from Visual Studio to the published Azure web app?

+0

問題をもう一度明らかにする。私たちが作成した.NET MVC Webアプリケーションは、Visual Studioから実行するとうまく動作します。 Azure SQL DBとAzure ADに接続することができます。 Azureアプリケーションサービスを作成してこのアプリケーションをデプロイすると、Azure AD認証ステップで前述のエラーが発生します。私はAD認証ステップを迂回すると、アプリケーションはAzure SQL DBに接続して正常に動作します。私の推測では、AzureのWebアプリケーションはwwwrootの下にあるApp_Dataフォルダを認識していないので、接続文字列の中でさまざまな方法を試してみてください。誰か助けてもらえますか? – ramesh

+0

コードを表示してください。 – mikalai

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" />

関連する問題