Commit d8aad764 authored by Aman Verma's avatar Aman Verma
Browse files

adding a config class

parent b6e2ae8b
......@@ -78,4 +78,5 @@ Enabled transaction logger and slf4jlogger
| name | value | description |
| --- | --- | --- |
| `tenantInfo.container.name` | `TenantInfo` | cosmos container name |
| `azure.cosmosdb.database` | ex `dev-osdu-r2-db` | cosmos databse name |
\ No newline at end of file
| `azure.cosmosdb.database` | ex `dev-osdu-r2-db` | cosmos database name |
| `storage_account` | ex `testStorage` | storage account name |
\ No newline at end of file
......@@ -17,10 +17,10 @@ package org.opengroup.osdu.azure.blobstorage;
import com.azure.identity.DefaultAzureCredential;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import org.opengroup.osdu.azure.di.BlobStoreConfiguration;
import org.opengroup.osdu.common.Validators;
import org.springframework.beans.factory.annotation.Autowired;
import javax.inject.Named;
import org.springframework.context.annotation.Lazy;
/**
* Implementation for IBlobServiceClientFactory.
......@@ -31,8 +31,8 @@ public class BlobServiceClientFactoryImpl implements IBlobServiceClientFactory {
private DefaultAzureCredential defaultAzureCredential;
@Autowired
@Named("STORAGE_ACCOUNT_NAME")
private String storageAccount;
@Lazy
private BlobStoreConfiguration blobStoreConfiguration;
private BlobServiceClient blobServiceClient;
......@@ -42,9 +42,9 @@ public class BlobServiceClientFactoryImpl implements IBlobServiceClientFactory {
*/
public BlobServiceClientFactoryImpl() {
Validators.checkNotNull(defaultAzureCredential, "Credential cannot be null");
Validators.checkNotNullAndNotEmpty(storageAccount, "KV URL");
Validators.checkNotNullAndNotEmpty(blobStoreConfiguration.getStorageAccountName(), "Storage account name cannot be null");
String endpoint = String.format("https://%s.blob.core.windows.net", storageAccount);
String endpoint = String.format("https://%s.blob.core.windows.net", blobStoreConfiguration.getStorageAccountName());
blobServiceClient = new BlobServiceClientBuilder()
.endpoint(endpoint)
.credential(defaultAzureCredential)
......
// Copyright © Microsoft Corporation
//
// Licensed 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.opengroup.osdu.azure.di;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
/**
* A configuration bean class to set up blob store related variables.
*/
@Configuration
@Getter
@Lazy
public class BlobStoreConfiguration {
@Value("${azure.storage.account-name}")
private String storageAccountName;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment