Writing from NAV to Azure Storage

CraigS
Member Posts: 5
I have an NAV implementation which is running on an Azure VM. I am writing out files to the server which are then ftp'd to a 3rd party warehouse.
I need users to be able to view and move these files from their local machines. So basically I need a file share which is accessible from both the server and the client pc.
The server and the client pc's are not on a shared domain. I thought I had a reasonably elegant solution in that I could create a file share using an Azure storage account. A "net use" function allows me to create a share on the server and also on the users pc's. This works very well and users can see directories and files in this share.
However, NAV does not seem to be able to write out to this directory. When I call MyFile.CREATE(.....) I simply get a "Could not find a part of the path 'F:\Warehouse\Outbound\SORD_SO00412.xml'." if I map the drive, or "I/O Error" if I use a UNC path.
I appreciate that this is likely due to the fact that this is not a "normal" windows directory. Has anyone manged to write to such a directory and have sample code they could share?
Thanks
Craig
I need users to be able to view and move these files from their local machines. So basically I need a file share which is accessible from both the server and the client pc.
The server and the client pc's are not on a shared domain. I thought I had a reasonably elegant solution in that I could create a file share using an Azure storage account. A "net use" function allows me to create a share on the server and also on the users pc's. This works very well and users can see directories and files in this share.
However, NAV does not seem to be able to write out to this directory. When I call MyFile.CREATE(.....) I simply get a "Could not find a part of the path 'F:\Warehouse\Outbound\SORD_SO00412.xml'." if I map the drive, or "I/O Error" if I use a UNC path.
I appreciate that this is likely due to the fact that this is not a "normal" windows directory. Has anyone manged to write to such a directory and have sample code they could share?
Thanks
Craig
0
Answers
-
Thanks Juhl. Unfortunately I don't think that is the answer. The issue I have is not writing from server to client or vice versa. I want the files to be written to a directory on the NAV server which is where the ftp process will pick them up and move them off site. I want users to be able to access that directory via a share in case they need to move files from an error directory to a processing directory. Doing this via a network share is preferable to them having to log onto the NAV server to do it.
Using an Azure shared directory for this works perfectly - except, I cannot write from NAV to this directory which is based on Azure storage.0 -
All fileaccess happens on the server, so what ever you program for the clients to use, will point at the server.
Make a page fill it with file-list and make actions to move or whatever using .Net.
Think you are overthinking/looking how easy this could be.
I always stream files from memory direct to ftp, without touching the file system.Follow me on my blog juhl.blog0 -
You could easily upload the files to azure blob storage using the .net api provided by Microsoft, and save the url to the nav record instead of the UNC path. That's what I've been doing for years and it hasn't failed me yet.0
-
EvR is right.
But all this is crossing the river to get water.
Create the data in memory using streamwriter. Send the stream to ftp instead of saving to file first.
All this can be done with standard .Net.
No need for ever using the file system to send a file to ftp server!Follow me on my blog juhl.blog0 -
I think the world has moved on from FTP
The great thing about Azure blob storage is that it's dirt-cheap and requires no maintenance and backups.
Using the azure api won't require you to save it to a file either. Just transfer a byte[] directly (or base64 encode it from memory).0 -
For future lost souls\readers of this post - as today I faced the same problem:
- If you can use just the API as suggested above, it's better.
- If you are in a Azure region where you can use Azure File Sync, it may solve your problem.
- For all the other cases, follow me.
The problem here is the following: you cannot map a drive to a network location and expect a windows service to read from it - if you Google this issue you will find a lot of information about it and some kind of not officially supported workaround.
A "clearer" solution actually is to map the drive from within the service; so if we need to reach the path from NAV, we will have to map the drive from C\AL code so that the NAV service will be able to reach it.
You could use Powershell, or just issue a "net use" command from NAV to map the drive; be careful as after rebooting the service (or the server) you "may" need to map the drive again (in my experience peersistent is useless for this scenario).
Bad (but working) Code Example://Build File locFileName:=FileManagement.ServerTempFileName('.txt'); locFile.WRITEMODE(TRUE); locFile.CREATE(locFileName); //Hardcoded command and drive, write better code for yourself locFile.WRITE('net use Z \\AZURESTORAGENAME /u:USERNAME ACCESSKEY /persistent:yes'); locFile.CLOSE(); FileRename.Move(locFileName,COPYSTR(locFileName,1,STRLEN(locFileName)-4)+'.bat'); locFileName:=COPYSTR(locFileName,1,STRLEN(locFileName)-4)+'.bat'; //Didn't want to change the setting on the service //Run It Process:=Process.Process(); Process.Start(locFileName); SLEEP(3000); //Empirical IF ERASE(locFileName) THEN; //Do whatever pleases you with your Z drive
Bye!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions