Yes, the code works. To test the overall functionality, I have implemented a 
small test app, looking at your code here: 
https://jclouds.apache.org/guides/azure-storage/ . I just pass an SAS as a 
credential and run the app, which manipulates blobs and containers in my own 
azure subscription. this is what I do (left alone some lines, not related to 
jclouds): 
```
        public static String storageAccountName = "-storage-account-name-";
        //here I am passing the SAS instead of SharedKey, but a SharedKey would 
also work.
        public static String storageAccountKey = 
"sv=2018-03-28&ss=b&srt=sco&sp=rwdlac&se=2019- 
        02-04T17:13:28Z&st=2019-02- 
        
04T09:13:28Z&spr=https&sig=TksMpiV1GiUqlzsaPWMko91bSAs%2Bt%2FPYvm7zTbQ%2F4ls%3D";
        public static String containerName = "-container-name-";
        public static String blobFullyQualifiedFileName = "-blob-name-fq-";
        public static String blobName = "-blob-name-1-";
        public static String blobName2 = "blob-name-2-";


        Iterable<Module> modules = ImmutableSet.<Module> of(new 
SLF4JLoggingModule()); 
        
        //here I am creating BlobStoreContext with the SAS key
        BlobStoreContext context = ContextBuilder.newBuilder("azureblob")
                                                .modules(modules)
                                .credentials(storageAccountName, 
storageAccountKey)
                                .buildView(BlobStoreContext.class);
                                        
        BlobStore blobStore = context.getBlobStore();   
        ByteSource payload1 = Files.asByteSource(new 
File(blobFullyQualifiedFileName));  
        
        Blob blobx = null;
        try {
                blobx = context.getBlobStore().blobBuilder(blobName2)
                        .payload(payload1)  // or InputStream
                        .contentLength(payload1.size())
                        .build();
        } catch (Exception e) {
                e.printStackTrace();
        }
        
        //put blob
        blobStore.putBlob(containerName, blobx);
        //create container
        blobStore.createContainerInLocation(null, "test");
        
        AzureBlobClient azureBlobClient = 
context.unwrapApi(AzureBlobClient.class);
        System.out.println(azureBlobClient);
        
        //checking if a blob exists
        boolean bool = blobStore.blobExists(containerName, blobName);
        System.out.println(bool); 
        
        //getting the blob 
        AzureBlob blob = azureBlobClient.getBlob(containerName, blobName);
        Payload pl = blob.getPayload();
        
        //signing the request
        HttpRequest req = context.getSigner().signGetBlob(containerName, 
blobName);
        String m = req.getMethod();
        String rl = req.getRequestLine();
        
        //getting blob properties
        Object object = azureBlobClient.getBlobProperties(containerName, 
blobName);
        System.out.println(object);
        context.close(); 
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1270#issuecomment-462648770

Reply via email to