Problem Uploading files using ASPUpload using Azure Storage File Service (Network Drive)

Aleks
Aleks used Ask the Experts™
on
We are having an issue when using ASPUpload (http://www.aspupload.com/) and a Network Drive plugged into a VM Azure Server

If we point our application (Classic ASP) to point to a computer drive (C:) for example, it will find it and upload documents without any issues.
If we point the path to be a Storage File Drive (Z://) says it can't find it. We read some and found that the path had to the something like this:

\\ourstorage.file.core.windows.net\ourfileshare

But the site says it cannot find the path with either Z or the path above.
After reading some documentation we found that we needed to add the line below, which we did then we get a 'username and password incorrect' Even though they are the correct ones. I tested by typing the path in windows explorer then entering the credentials.

upload.LogonUser "", "username", "password"

Anyone with experience doing this will be greatly appreciated.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
I have a feeling aspupload will not work for that.  

My suggestion is to either follow the powershell option https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-powershell or php https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-php?tabs=windows

In either case, you would set up your script to accept a parameter for the file and have your classic asp code send the data via xmlhttp request.

The php example shows
 
<?php
$uploadFile = $_POST['filename'] // THIS WILL BE YOUR FILE NAME;
$passcode = $_POST['passcode']; //POST A PASSCODE IN YOUR ASP PAGE TO PREVENT THIS FROM FIRING BY ACCIDENT

// ASSUME PASSCODE IS 'ABC123'

if $passcode != 'ABC123' {
    die('Please see the site admin');  // If wrong passcode, stop processing and print out error to screen
}


 $myfile = fopen($passcode, "w") or die("Unable to open file!");
    fclose($myfile);

    # Upload file as a block blob
    echo "Uploading BlockBlob: ".PHP_EOL;
    echo $fileToUpload;
    echo "<br />";

    $content = fopen($fileToUpload, "r");

    //Upload blob
    $blobClient->createBlockBlob($containerName, $fileToUpload, $content);

Open in new window


To modify, call the file upload.php
  $myfile = fopen("HelloWorld.txt", "w") or die("Unable to open file!");
    fclose($myfile);

    # Upload file as a block blob
    echo "Uploading BlockBlob: ".PHP_EOL;
    echo $fileToUpload;
    echo "<br />";

    $content = fopen($fileToUpload, "r");

    //Upload blob
    $blobClient->createBlockBlob($containerName, $fileToUpload, $content);

Open in new window


Now for your asp code https://support.microsoft.com/en-us/help/290591/how-to-submit-form-data-by-using-xmlhttp-or-serverxmlhttp-object
<%@ Language=vbScript%>
<%

fileToUpload = "myFile.txt"

DataToSend = "passcode=ABC123&file="&fileToUpload
dim xmlhttp 
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST","http://mysite.com/upload.php",false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send DataToSend
Response.ContentType = "text/plain"    ' ******** CHANGED TO TEXT/PLAIN ******************
Response.Write xmlhttp.responseText   ' *********CHANGED TO RESPONSETEXT *****************
        Set xmlhttp = nothing
%>

Open in new window


If you are uploading the file to your server first, you can use aspupload to go to your own server, from there grab the file name to use in your xmlhttppost page for field fileToUpload.

If you prefer to use powershell and not instal php, you could run a powershell script using vbscript too https://blogs.technet.microsoft.com/heyscriptingguy/2012/07/18/how-to-use-vbscript-to-run-a-powershell-script/

Author

Commented:
Sorry if I wasn't clear.
This is a web application trying to upload the file.

The problem is not the upload mechanism. If we pick a local drive it will upload with no problem. But if I map it to the FileStorage drive, which is mapped as "Z" drive in the computer then it says the path cannot be found.
If we use the UNC path then it does find it but says credentials are incorrect.
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
You are using
Set Upload = Server.CreateObject("Persits.Upload")
Upload.LogonUser "mydomain", "Administrator", "xxxxxxxxx"

Open in new window


I wonder if the domain has to be
http://myaccount.blob.core.windows.net/mycontainer/myblob      
or
http://myaccount.blob.core.windows.net/mycontainer
or
http://myaccount.blob.core.windows.net
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Author

Commented:
We have tried all sort of combinations. So far no luck.
Tonight we will try creating a local account and will test with that local user which should have access to the Z drive.

Will let you know of the results.
We thought the domain would be the above as you stated, only without the http:
Do you think we should try with http:  ?
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
I'm not sure. I would do the same thing as you and just try different combinations though I would probably  just give up and go for the php or powershell example code since that works.

I think this is really a rest call and not sure if aspupload will work for that https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-service-properties

It may just be the x-ms-client-request-id

Author

Commented:
Yeah ... we will try to use the code we already have in place using a local drive Z with a local user that has permissions to see the drive.
If that doesn't work then we will try and see if we can clone the drive to another VM overnight to have a backup of the files in place.
The idea was to have a shared File Storage that both Vms could see.

Author

Commented:
This is a FileStorage drive that uses SMB protocol. Maybe thats the issue ... anyhow. Will let you know if using local Z drive works later tonight.
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
If you are moving it locally, it may be easier to use FileSystemObject https://www.w3schools.com/asp/met_movefile.asp

<%
dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject")
fs.MoveFile "c:\web\*.gif","c:\images\"
set fs=nothing
%>

Open in new window

Big MontyWeb Ninja at large

Commented:
just throwing this out there for something to try...

Are you able to map the Z:\ to a virtual directory? if you can, I would try to do that, then all you have to do is set the permissions. Again, not sure if this is a possibility, but worth looking into

Author

Commented:
How would I go about doing that?  
You mean an IIS directory ?

If I do that how would I map to that drive in the application?  currently it points to "Z://foldername"
Big MontyWeb Ninja at large

Commented:
remembering from our days of working offline together, I seem to recall you having them in your setup (assuming this is for BD), so it should be easy to do...when i say "easy", that depends what kind of permissions you have to the z:\. If it's something you have full control over, then it's a matter of going to IIS and configuring it.

Here's a good video explaining how to set it up:

https://www.youtube.com/watch?v=lx7gAqloikE

Author

Commented:
It is for BD. Currently we are storing all attachments in drive "F", which is a local drive attached to an Azure VM.
It works perfectly. The SQL Server is now on a separate server to which the VM connects to.
The problem is that if the VM goes down for any reason we have a backup server that also connects to the SQL server, but the attached documents are still on the VM which when down cannot be retrieved.
We added a Storage Account (Azure) with File Share service, so now that shows as drive Z plugged into the VM. I can see it from windows explorer. It uses SMB to communicate with the drive which requires port 445 open, we already did this, yet when we try to write or read from that drive using either Z://path or the UNC path we can't access the drive via BD.
We can however using windows explorer.

https://azure.microsoft.com/en-us/services/storage/files/
Big MontyWeb Ninja at large

Commented:
w/out seeing the actual setup, it's hard to recommend anything else.  were you able to set a virtual directory (even as a test) on your z:\ drive. Try to get that configured as a good starting point. I am also always available offline as well to help out.

Author

Commented:
I asked for help with Azure people, if that doesn't work Ill give you a shout.  :)
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
I am sorry if you have already tried this, but have you try talking to ASPUpload support folks?

Author

Commented:
Actually Azure just confirmed that their protocol for File Storage does not currently support Web Applications.
So we went with a different approach.

I am not sure how to close this ticket without points assigned  :$
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
> I am not sure how to close this ticket without points assigned  

If you can, briefly explain what you did to solve your issue and why and then accept that as the solution. This will help others.
Commented:
Since web applications cannot save to the file storage what we did was to run a windows task that would copy the files over from the server into the storage, instead of saving to the storage directly.
This means we keep a copy locally and one in the storage, which is not a bad thing since it works as a backup.
And we scheduled the script to run every 15 min. So we are only 15 min behind in the worse case scenario.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial