private static String getCosmosKey(AzureCloudConfig azureCloudConfig) {
    if (!azureCloudConfig.cosmosKey.isEmpty()) {
      return azureCloudConfig.cosmosKey;
    }
    if (azureCloudConfig.cosmosKeySecretName.isEmpty() || azureCloudConfig.cosmosVaultUrl.isEmpty()) {
      throw new IllegalArgumentException(
          String.format("One of the required configs for fetching the cosmos key from a keyvault (%s, %s) missing",
              AzureCloudConfig.COSMOS_KEY_SECRET_NAME, AzureCloudConfig.COSMOS_VAULT_URL));
    }
    // check that all required azure identity configs are present if keyvault lookup is used.
    AzureUtils.validateAzureIdentityConfigs(azureCloudConfig);
    SecretClient secretClient = new SecretClientBuilder().vaultUrl(azureCloudConfig.cosmosVaultUrl)
        .credential(AzureUtils.getClientSecretCredential(azureCloudConfig))
        .buildClient();
    return secretClient.getSecret(azureCloudConfig.cosmosKeySecretName).getValue();
  }
Fetch the key either directly from configs, or indirectly by looking for it in an Azure KeyVault.
@param azureCloudConfig the config
@return the CosmosDB key.
ambry-cloud/src/main/java/com/github/ambry/cloud/azure/CosmosDataAccessor.java