I am trying to access a fileshare to upload to and download files from it, using the java code example given on the azure docs site here: https://learn.microsoft.com/en-us/azure/java/java-sdk-azure-get-started
I have a microsoft azure storage account setup, a fileshare with one file on it, I have used the correct connection string as per the example. At the minute I am running this code via a piece of testcode with a main method which calls the upload or download methods, I run or debug it as java application, and I get the error: 503 service unavailable.
Can anyone suggest what is causing this, or if there is different/further/better set of instructions I should be following?
Edit: In response to the first reply below, here is the code example:
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.InvalidKeyException;
import com.microsoft.azure.storage.*;
import com.microsoft.azure.storage.file.*;
/**
* Coded based on "Develop for Azure files with Java" tutorial from here:
* https://learn.microsoft.com/en-au/azure/storage/files/storage-java-how-to-use-file-storage
*/
public class myAzureExample {
// Configure the connection-string with your values
public static final String storageConnectionString =
"DefaultEndpointsProtocol=http;" +
"AccountName=myAccountName;" +
"AccountKey=myAccountKey";
public static void main(String[] args) throws URISyntaxException, StorageException, InvalidKeyException, IOException {
downloadFile();
}
public static void downloadFile() throws InvalidKeyException, URISyntaxException, StorageException, IOException {
CloudFileShare share = getShare();
//Get a reference to the root directory for the share.
CloudFileDirectory rootDir = share.getRootDirectoryReference();
//Get a reference to the directory that contains the file
CloudFileDirectory sampleDir = rootDir.getDirectoryReference("sampledir");
//Get a reference to the file you want to download
CloudFile file = sampleDir.getFileReference("SampleFile.txt");
//Write the contents of the file to the console.
System.out.println(file.downloadText());
}
private static CloudFileShare getShare() throws URISyntaxException, InvalidKeyException, StorageException {
CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
CloudFileClient fileClient = storageAccount.createCloudFileClient();
// Get a reference to the file share
CloudFileShare share = fileClient.getShareReference("portalshare");
return share;
}
}