Если вы хотите сохранить файл в Azure озере данных Gen2 в Azure блоках данных, выполните следующие шаги
- Создайте учетную запись Azure Data Lake Storage Gen2.
az login
az storage account create \
--name <account-name> \
--resource-group <group name> \
--location westus \
--sku Standard_RAGRS \
--kind StorageV2 \
--enable-hierarchical-namespace true
Создайте принципала службы и назначьте участника службы хранилища BLOB-объектов для sp в области учетной записи хранения Data Lake Storage Gen2
az login
az ad sp create-for-rbac -n "MyApp" --role "Storage Blob Data Contributor" \
--scopes /subscriptions/<subscription>/resourceGroups/<resource-group>/providers/Microsoft.Storage/storageAccounts/<storage-account>
Создать кластер Spark в Azure Databricks
mount Azure data lake gen2 в Azure Databricks (python)
configs = {"fs.azure.account.auth.type": "OAuth",
"fs.azure.account.oauth.provider.type": "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider",
"fs.azure.account.oauth2.client.id": "<appId>",
"fs.azure.account.oauth2.client.secret": "<clientSecret>",
"fs.azure.account.oauth2.client.endpoint": "https://login.microsoftonline.com/<tenant>/oauth2/token",
"fs.azure.createRemoteFileSystemDuringInitialization": "true"}
dbutils.fs.mount(
source = "abfss://<container-name>@<storage-account-name>.dfs.core.windows.net/folder1",
mount_point = "/mnt/flightdata",
extra_configs = configs)
сохранить json в azure озеро данных gen2
dbutils.fs.put("/mnt/flightdata/<file name>", """
<json string>
""", True)
![enter image description here](https://i.stack.imgur.com/Uita2.png)
введите описание изображения здесь