rdblue commented on code in PR #4465:
URL: https://github.com/apache/iceberg/pull/4465#discussion_r841278496


##########
azure/src/main/java/org/apache/iceberg/azure/blob/AzureBlobClientFactory.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iceberg.azure.blob;
+
+import com.azure.core.credential.AzureSasCredential;
+import com.azure.storage.blob.BlobClient;
+import com.azure.storage.blob.BlobClientBuilder;
+import com.azure.storage.common.StorageSharedKeyCredential;
+import java.util.Optional;
+import org.apache.iceberg.azure.AuthType;
+import org.apache.iceberg.azure.AzureProperties;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AzureBlobClientFactory {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(AzureBlobClientFactory.class);
+
+  private AzureBlobClientFactory() {
+  }
+
+  public static BlobClient createBlobClient(AzureURI azureURI, AzureProperties 
azureProperties) {
+    final String storageAccount = azureURI.storageAccount();
+    final BlobClientBuilder builder = new BlobClientBuilder();
+
+    final Optional<String> connectionString = 
azureProperties.connectionString(storageAccount);
+    // Connection string should contain storage endpoint and required auth 
properties.
+    if (connectionString.isPresent()) {
+      LOG.debug("Using azure storage connection string to build the blob 
client for {}", storageAccount);
+      Preconditions.checkArgument(!connectionString.get().isEmpty(), 
"Connection string cannot be empty.");
+      builder.connectionString(connectionString.get());
+    } else {
+      final String endpoint = storageEndpoint(storageAccount, azureProperties);
+      LOG.debug("Using {} endpoint for {}", endpoint, storageAccount);
+      builder.endpoint(endpoint);
+      final AuthType authType = azureProperties.authType(storageAccount);
+      setAuth(storageAccount, authType, azureProperties, builder);

Review Comment:
   Why is `setAuth` not required when using a connection string?



-- 
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: dev-unsubscr...@iceberg.apache.org

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

Reply via email to