You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/02/17 17:20:59 UTC

[GitHub] [druid] abhishekagarwal87 commented on a change in pull request #12266: Adding Shared Access resource support for azure

abhishekagarwal87 commented on a change in pull request #12266:
URL: https://github.com/apache/druid/pull/12266#discussion_r809290265



##########
File path: extensions-core/azure-extensions/src/main/java/org/apache/druid/storage/azure/AzureStorageDruidModule.java
##########
@@ -125,17 +129,36 @@ public void configure(Binder binder)
   @LazySingleton
   public Supplier<CloudBlobClient> getCloudBlobClient(final AzureAccountConfig config)
   {
+    if ((config.getKey() != null && config.getSharedAccessStorageToken() != null)
+        ||
+        (config.getKey() == null && config.getSharedAccessStorageToken() == null)) {
+      throw new ISE("Either set 'key' or 'sharedAccessStorageToken' in the azure config but not both");
+    }
     return Suppliers.memoize(() -> {
       try {
-        CloudStorageAccount account = CloudStorageAccount.parse(
-            StringUtils.format(
-                STORAGE_CONNECTION_STRING,
-                config.getProtocol(),
-                config.getAccount(),
-                config.getKey()
-            )
-        );
-        return account.createCloudBlobClient();
+        final CloudStorageAccount account;
+        if (config.getKey() != null) {
+          account = CloudStorageAccount.parse(
+              StringUtils.format(
+                  STORAGE_CONNECTION_STRING_WITH_KEY,
+                  config.getProtocol(),
+                  config.getAccount(),
+                  config.getKey()
+              )
+
+          );
+          return account.createCloudBlobClient();
+        } else if (config.getSharedAccessStorageToken() != null) {
+          account = CloudStorageAccount.parse(StringUtils.format(
+              STORAGE_CONNECTION_STRING_WITH_TOKEN,
+              config.getProtocol(),
+              config.getAccount(),
+              config.getSharedAccessStorageToken()
+          ));
+          return account.createCloudBlobClient();
+        } else {
+          throw new ISE("Either set 'key' or 'sharedAccessStorageToken' in the azure config but not both");

Review comment:
       ```suggestion
             throw new ISE("None of 'key' or 'sharedAccessStorageToken' is set in the azure config.  Please refer to azure extension documentation.");
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org