Link to home
Start Free TrialLog in
Avatar of Aleks
AleksFlag for United States of America

asked on

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

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.
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

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/
Avatar of Aleks

ASKER

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.
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
Avatar of Aleks

ASKER

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:  ?
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
Avatar of Aleks

ASKER

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.
Avatar of Aleks

ASKER

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

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
Avatar of Aleks

ASKER

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"
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
Avatar of Aleks

ASKER

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/
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.
Avatar of Aleks

ASKER

I asked for help with Azure people, if that doesn't work Ill give you a shout.  :)
I am sorry if you have already tried this, but have you try talking to ASPUpload support folks?
Avatar of Aleks

ASKER

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  :$
> 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.
ASKER CERTIFIED SOLUTION
Avatar of Aleks
Aleks
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial