locked
Deployment error - Web deployment task failed RRS feed

  • Question

  • User521171331 posted

    Hi, I try my first azure deployment. It is just a sample project. 

    But, it shows this error:

    Web deployment task failed. (Cannot attach the file 'C:\Users\User\Desktop\WebApplication1\WebApplication1\App_Data\aspnet-WebApplication1-20170509023603.mdf' as database 'aspnet-WebApplication1-20170509023603'.)

    How do I fix it?

    Tuesday, May 9, 2017 6:37 AM

All replies

  • User753101303 posted

    Hi,

    Seems you have a hardcoded path in your web.config file? Usually you are using something such as |DataDirectory|\yourDataFile.mdf which points to App_Data regardless of where your app is actually installed.

    Edit: this is discussed at https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx for the AttachDBFilename keyword. BTW this is your own VM or app service. I'm not sure it works in this later case (I doubt they install a local db engine). Anyway beyond a proof of concept it's likely best to connect explicitely to a SQL Server instance rather than to use an App_Data database file (for example you couldn't then create multiple instance for your web sites as they would have each their own data file rather than sharing a db etc...)

    Tuesday, May 9, 2017 4:17 PM