locked
SqlFileStream - The device is not ready error RRS feed

  • Question

  • Hi All,

    apologies if this is wrong forum, and if so can mod please move to correct place.

    I am having an issue with SQLFileStream that I will try to explain details below and if anyone can help would be appreciated.

    I have a web server and a sql server in hyper-v.  The webserver is running mvc app that uses filestream to upload/download documents from the database.  This was all working perfectly on my old server set up which was hyper-v host with these 2 machines below it.

    Since then, I have moved to azure and created a virtual network that contains VM's for my 2 servers, both on the same domain.  This set up is the same conceptually, and the website can access the database no problem and works fine for everything except filestream.

    When it tries to run any line similar to

    using (SqlFileStream sqlfilestream = new SqlFileStream(filepath, txContext, System.IO.FileAccess.Read))

    if gives me an error

    [Win32Exception (0x80004005): The device is not ready]
       System.Data.SqlTypes.SqlFileStream.OpenSqlFileStream.....

    I created a test app that connects to the database and reads a file and saves out to the file system normally.  When I run this locally on the SQL server it works fine, accesses the database, reads the file out and saves to desktop.  When I try running this app on the web server it throws the same (The device is not ready) error.

    Like I said, everything else works fine, it is just the filestream part not working.  I have tried disabling firewalls, turning filestream off and back on again etc but nothing seems to work.

    Has anyone else experienced this, or have any insight as to what I should try next as I am at a complete loss? 

    Thanks in advance for any help/advice you can provide.

    Cheers


    Andy

    • Moved by Bob BeaucheminEditor Thursday, August 4, 2016 3:10 PM Moving to forum with most filestream data access questions/answers for best results
    Wednesday, August 3, 2016 12:12 PM

Answers

  • Hi Bob,

    I have resolved this issue to you can close the thread.

    For anyone else who encounters this, the issue was with services on Azure.  It turned out that when I was turning on the file and printer sharing and saving, in the background azure was turning it off (or not processing request).

    I think this was due to 2 of the services required being set to manual/disabled.  I switched these both to automatic and restarted machine and its working.  these services were

    Upnp device host

    function discovery resource publication

    Not sure if that was what was causing the problem 100% but it worked for us so something to check if anyone else experiences.

    Thanks for your help.

    Andy

    Tuesday, August 9, 2016 9:26 AM

All replies

  • The forum for SqlClient client-side is MSDN forums, Managed Provider forum. I'll move it there soon. This one's for SQLCLR (SQL objects like sprocs and UDTs written in .NET). 

    As far as filestream remote client, a few simple things to check:

    Turning filestream off and back on again... there are actually four settings. Do you have SQL Server filestream enabled for *remote* file access (not just file access) in the startup parameters? And did you restart SQL Server after changing this setting?

    Do you have Windows file sharing (ie, SMB protocol) enabled on the SQL Server machine?  Remote client access to filestream uses SMB.

    Are you accessing SQL Server using a *Windows* login to SQL Server? (this one's last because I don't think local client access through SqlFileStream will work with a SQL login to SQL Server either, and you said that worked).

    Wednesday, August 3, 2016 10:07 PM
    Answerer
  • Hi Bob,

    thanks for your reply.  in answer to your questions.  I do not know what startup parameters to set and cant see any on MSDN however I have it set as below in config manager

    I have file sharing turned on and rules enabled in firewall (although I even turned off the firewalls incase it was something here).

    and yes, I have created a domain account called filestream that the IIS apppool is running under.  this user has been given access to the database, which works as the rest of the site works fine.  when I said running locally I meant I was running the test app on the sql machine but was using a windows login.  using this same windows login on the webserver and running the app gives the "the device is not ready" error.

    SqlConnection con = new SqlConnection("Integrated Security=true; server=XXXXXXXX");

    Like I said we had this working perfectly when running on 2 servers in hyper-v and I have checked every setting that I can think of and compared the machines, but since moving to azure I can't get it to work.  I know I must be missing something simple but for the life of me cant find it.

    Any advice/help is appreciated.

    Thanks for your time.

    Andy

    Thursday, August 4, 2016 9:21 AM
  • Seems like the SQL Server Data Access has a lot of activity on how to set up filestream. Because this may be a setup/configuration problem, moving it there, for best response.

    Thursday, August 4, 2016 3:10 PM
    Answerer
  • Hi Bob,

    I have resolved this issue to you can close the thread.

    For anyone else who encounters this, the issue was with services on Azure.  It turned out that when I was turning on the file and printer sharing and saving, in the background azure was turning it off (or not processing request).

    I think this was due to 2 of the services required being set to manual/disabled.  I switched these both to automatic and restarted machine and its working.  these services were

    Upnp device host

    function discovery resource publication

    Not sure if that was what was causing the problem 100% but it worked for us so something to check if anyone else experiences.

    Thanks for your help.

    Andy

    Tuesday, August 9, 2016 9:26 AM