web stats
SMB with Azure File Storage - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 09-14-2016, 05:45 AM
saurmirth saurmirth is offline
What's HL7?
 
Join Date: Sep 2016
Posts: 5
saurmirth is on a distinguished road
Default SMB with Azure File Storage

Has any one tried accessing Azure file storage using smb File reader?

More details about Azure file storage here.https://azure.microsoft.com/en-in/do...-to-use-files/

Since I could not make it work using native SMB file reader. I used libraries provided by microsoft(see the java tab in above link for more details, will share mirth transformer code shortly); though would like the native thing to work
Reply With Quote
  #2  
Old 09-14-2016, 08:26 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

If you want to work with an Azure storage system, there is a java library from azure with the name of microsoft-windowsazure-api-0.4.6.

The installation is easy, You need to upload/add it inside your mirth/custom-lib/lib folder and then restart.

And then, you can try setting up the smb file reader as you want.
Reply With Quote
  #3  
Old 09-14-2016, 09:27 AM
saurmirth saurmirth is offline
What's HL7?
 
Join Date: Sep 2016
Posts: 5
saurmirth is on a distinguished road
Default Using the library from MS...but not sure how to use smb reader

I am already using the library as an alternative

However I think the smb reader won't be able to use them. Would they?
Out of box smb reader - I could not make it work with the azure storage..

Here's the current code I am using...

Code:
// get the jar files from github and include them as dependencies
importPackage(com.microsoft.azure.storage.*);
importPackage(com.microsoft.azure.storage.file.*);
// Configure the connection-string with your values
SERVER_NAME = "resource111111";
ACCOUNT_KEY = "verylonggibberishstring";
SHARE_NAME = "rootshare";//rootdirectory on your server

storageConnectionString =
    "DefaultEndpointsProtocol=http;" +
    "AccountName="+SERVER_NAME+";" +
    "AccountKey="+ACCOUNT_KEY;
s1 = new com.microsoft.azure.storage.StorageCredentialsAccountAndKey(SERVER_NAME,ACCOUNT_KEY);
// Use the CloudStorageAccount object to connect to your storage account
try {
    storageAccount = new com.microsoft.azure.storage.CloudStorageAccount(s1);
} catch (invalidKey) {
    // Handle the exception
    logger.info(invalidKey)
}
// Create the file storage client.
fileClient = storageAccount.createCloudFileClient();
// Get a reference to the file share
share = fileClient.getShareReference(SHARE_NAME);
//Get a reference to the root directory for the share.
rootDir = share.getRootDirectoryReference();

transfer = function(inpath,outpath){
	mydir = rootDir.getDirectoryReference(inpath);
	list1 = mydir.listFilesAndDirectories();
	itr=list1.iterator();
	while(itr.hasNext()){
		cloudfile=itr.next();
		try { 
		    cloudfile.downloadToFile(outpath+cloudfile.getName());
		    cloudfile.deleteIfExists();
		} catch (e) {
		    
		}
	}
}

inpath="sourcefolder/subfolder"; //give the folder name on azure
outpath="C:/Localfolder/"; // local folder. add extra / at end

transfer(inpath,outpath)
Reply With Quote
  #4  
Old 09-14-2016, 10:06 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

Did you try creating File Reader with smb as a method? I think it should work after you upload that library.
Reply With Quote
  #5  
Old 09-14-2016, 10:03 PM
saurmirth saurmirth is offline
What's HL7?
 
Join Date: Sep 2016
Posts: 5
saurmirth is on a distinguished road
Default

Tried your suggestion... but no conenction...

How will the smb reader know to use MS libraries?
Reply With Quote
  #6  
Old 09-15-2016, 06:54 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,123
narupley is on a distinguished road
Default

Does the Microsoft-specific library do anything special on top of the SMB protocol? If so, then it makes sense that the standard File Reader doesn't work.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
Reply

Tags
azure, smb

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 05:07 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation