Search code examples
databricksazure-databricks

Getting StringIndexOutOfBoundsException while mounting a storage container in Azure databricks


When i try to mount a storage container in azure databricks , I get the below error . This container is not mounted, hence I am mounting it

 scope = 'myscope'
 storage_account_name = dbutils.secrets.get(scope=scope, key="AccessKey")
 storage_account_access_key = dbutils.secrets.get(scope=scope, key="Accessprimary-key")
 cont="reference"
 configs = {f"fs.azure.account.key.{storage_account_name}.blob.core.windows.net":storage_account_access_key}

 dbutils.fs.mount(
  source = f"wasbs://{cont}@{storage_account_name}.blob.core.windows.net/",
  mount_point = f"/mnt/{cont}",
  extra_configs = configs
)

Can someone help help on fixing this issue . Basically i want to mount the container . The scope and secrets are already set and it works perfecting if i do unmount any existing containers

Error :

 ExecutionError                            Traceback (most recent call last)
 <command-3711978919081072>   in <module>
   32 
   33 
  ---> 34 dbutils.fs.mount(
 35   source = f"wasbs://{cont}@{storage_account_name}.blob.core.windows.net/",
 36   mount_point = f"/mnt/{cont}",

/databricks/python_shell/dbruntime/dbutils.py in f_with_exception_handling(*args, **kwargs)
387                     exc.__context__ = None
388                     exc.__cause__ = None
--> 389                     raise exc
390 
391             return f_with_exception_handling

ExecutionError: An error occurred while calling o388.mount.
: shaded.databricks.org.apache.hadoop.fs.azure.AzureException: 
java.lang.StringIndexOutOfBoundsException: String index out of range: 11

Solution

  • I think that you have a problem with this line:

    storage_account_name = dbutils.secrets.get(scope=scope, key="AccessKey")
    

    This variable should be the storage account name, but it looks like you're pulling off the access key for that storage account.