Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

### Updates
* Updated the BrokerProtocol type for Kafka Extension.
* Add check for all connection env variables to configure managed identity

### Breaking changes
* to be update
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Object createInstance(BlobClientMetaData metaData) throws Exception {
String envVar = metaData.getConnectionEnvVar();
String configValue = System.getenv(envVar);

if (configValue == null || configValue.isEmpty()) {
if (!environmentVariablesArePresent(envVar)) {
throw new SdkHydrationException("No environment variable set for: " + envVar);
}

Expand All @@ -35,7 +35,7 @@ public Object createInstance(BlobClientMetaData metaData) throws Exception {
Object blobBuilder = blobBuilderClass.getDeclaredConstructor().newInstance();

// Step 2: If configValue is a connection string, do the existing approach
if (isConnectionString(configValue)) {
if (configValue != null && isConnectionString(configValue)) {
LOGGER.info("Detected connection string usage from: " + envVar);

Method conn = blobBuilderClass.getMethod("connectionString", String.class);
Expand Down Expand Up @@ -87,6 +87,24 @@ public Object createInstance(BlobClientMetaData metaData) throws Exception {
return blobClient;
}

private boolean environmentVariablesArePresent(String envVar){
final String configValue = System.getenv(envVar);
final String accountName = System.getenv(envVar + "__accountName");
final String blobServiceUri = System.getenv(envVar + "__blobServiceUri");
final String serviceUri = System.getenv(envVar + "__serviceUri");

if(configValue != null && !configValue.isEmpty()){
return true;
}
if( (accountName != null && !accountName.isEmpty()) ||
(blobServiceUri != null && !blobServiceUri.isEmpty()) ||
(serviceUri != null && !serviceUri.isEmpty())
){
return true;
}
return false;
}

/**
* Decide if configValue is likely a connection string by checking for well-known keywords.
*/
Expand Down