The Blob Storage Interface class
azure_helper.utils.blob_storage_interface
BlobStorageInterface
Source code in azure_helper/utils/blob_storage_interface.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
__init__(storage_acct_name, storage_acct_key)
Class responsible to interact with an existing Azure Storage Account.
It uses a connection string to connect to the Storage Account.
Information
To get the key of this storage account we use the following command with the azure-cli.
This class is responsible for :
- Creating a container in the storage account.
- Uploading a dataframe (as a
csv
for now) inside a blob in one of the container of the storage account. - Download a
csv
from a blob in one of the container of the storage account and render it as a pandas dataframe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
storage_acct_name |
str
|
The name of the storage account to which you want to connect. |
required |
storage_acct_key |
str
|
The account key of the storage account. |
required |
Source code in azure_helper/utils/blob_storage_interface.py
create_container(container_name)
Create a container inside the storage account.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
container_name |
str
|
the name of the container you want to create. This name can only contains alphanumeric numbers and dashes '-'. |
required |
Source code in azure_helper/utils/blob_storage_interface.py
upload_df_to_blob(dataframe, container_name, blob_path)
Upload a pandas dataframe as a csv
file inside a blob.
Eg the following code.
Upload the dataframes x_train
and y_train
as x_train.csv
and y_train.csv
in the following way.
Attention
As of now, there is no data versioning. Meaning that if the blob_path
already exists, it will be
overwritten with new datas.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
pd.DataFrame
|
The dataframe you want to upload. |
required |
container_name |
str
|
The name of the container on which you want to upload the dataframe. |
required |
blob_path |
str
|
The path to the csv |
required |
Source code in azure_helper/utils/blob_storage_interface.py
download_blob_to_df(container_name, blob_path)
Download a csv
file a the given blob_path
location and renders it as a pandas datatrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
container_name |
str
|
The name of the container. |
required |
blob_path |
str
|
The path to the |
required |
Returns:
Type | Description |
---|---|
pd.DataFrame
|
pd.DataFrame: the |