当前位置: 首页 > 知识库问答 >
问题:

续订服务主体后,Azure Databricks作业无法访问ADLS存储

谭翰海
2023-03-14

Database ricks作业用于连接到ADLS G2存储并成功处理文件。

最近,在更新了服务主体机密,并更新了Key-vault中的机密之后,现在作业正在失败。

使用databricks cli<code>databricks-secrets list scopes--profile mycluster</code>,我能够识别正在使用的键值,还验证了相应的密钥是否正确更新。

在笔记本中,我遵循了链接并能够访问ALDS

下面我用来测试密钥保管库值,以访问ADLS。

scopename="name-of-the-scope-used-in-databricks-workspace"

appId=dbutils.secrets.get(scope=scopename,key="name-of-the-key-from-keyvault-referring-appid")
directoryId=dbutils.secrets.get(scope=scopename,key="name-of-key-from-keyvault-referring-TenantId")
secretValue=dbutils.secrets.get(scope=scopename,key="name-of-key-from-keyvaut-referring-Secretkey")
storageAccount="ADLS-Gen2-StorageAccountName"

spark.conf.set(f"fs.azure.account.auth.type.{storageAccount}.dfs.core.windows.net", "OAuth")
spark.conf.set(f"fs.azure.account.oauth.provider.type.{storageAccount}.dfs.core.windows.net", "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider")
spark.conf.set(f"fs.azure.account.oauth2.client.id.{storageAccount}.dfs.core.windows.net", appid)
spark.conf.set(f"fs.azure.account.oauth2.client.secret.{storageAccount}.dfs.core.windows.net", secretValue)
spark.conf.set(f"fs.azure.account.oauth2.client.endpoint.{storageAccount}.dfs.core.windows.net", f"https://login.microsoftonline.com/{directoryid}/oauth2/token")
dbutils.fs.ls("abfss://<container-name>@<storage-accnt-name>.dfs.core.windows.net/<folder>")

对于附加的群集,上面会成功显示 ADLS G2 存储中的文件夹/文件列表。

用于创建挂载点的代码,它使用了旧的机密信息。

scope_name="name-of-the-scope-from-workspace"
directoryId=dbutils.secrets.get(scope=scope_name, key="name-of-key-from-keyvault-which-stores-tenantid-value")
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": dbutils.secrets.get(scope=scope_name, key="name-of-key-from-key-vault-referring-to-clientid"),
          "fs.azure.account.oauth2.client.secret": dbutils.secrets.get(scope=scope_name, key="name-of-key-from-key-vault-referring-to-secretvalue-generated-in-sp-secrets"),
          "fs.azure.account.oauth2.client.endpoint": f"https://login.microsoftonline.com/{directoryId}/oauth2/token"}

storage_acct_name="storageaccountname"
container_name="name-of-container"

mount_point = "/mnt/appadls/content"
if not any(mount.mountPoint == mount_point for mount in dbutils.fs.mounts()):
  print(f"Mounting {mount_point} to DBFS filesystem")
  dbutils.fs.mount(
    source = f"abfss://{container_name}@{storage_acct_name}.dfs.core.windows.net/",
    mount_point = mount_point,
    extra_configs = configs)
else:
  print("Mount point {mount_point} has already been mounted.")

在我的例子中,密钥库是用clientid、租户/目录id、SP密钥更新的。

更新服务原则后,当访问/mnt/path时,我看到以下异常。

...
response '{"error":"invalid_client","error_description":"AADSTS7000215: Invalid client secret is provided.

我唯一能想到的是挂载点是用上面代码中的旧秘密创建的。续订服务主体后,我需要卸载并重新创建装载点吗?

共有1个答案

南宫博简
2023-03-14

所以我终于尝试卸载并挂载ADLS G2存储,现在我可以访问它了。

我没想到配置会以某种方式持久化。仅仅更新服务主体秘密就足够了。

 类似资料:
  • 工作节点1上的Curl对群集IP来说是最合适的(这是运行pod的节点) Curl在其他工作节点上也失败:

  • 问题内容: 我已经按照Kelsey Hightower的指示从头开始创建了一个kubernetes集群。经过检查,一切正常,没有任何错误,但是在部署了第一个应用程序之后,我发现我的应用程序无法解析DNS。 我检查了我的coredns日志,并看到以下条目: 加上Kelsey的文档,我已经在Docker之上安装了calico。 我的怀疑: 我已经在Docker之上安装了Calico,但是我的kubel

  • 我已经安装了Jenkins和Sonarqube5.1.1(也尝试了LTS),它运行在Ubuntu服务器上,可以从外部访问。我已经安装了Jenkins SonarQube插件,一切都差不多工作了。如果我在Jenkins中将SonarQube服务器URL设置为localhost,那么一切都很好。但是到SonarQube(在Jenkins内部)的链接将指向localhost,当我从外部访问Jenkins

  • 我无法通过集装箱中的港口连接到django。我使用的地址是:0.0.0.0.:8000,请参阅:http://joxi.ru/Dr8MeGLhkBWnLm.我正在用一个命令创建一个图像和一个容器:“docker compose up-d”。 docker-compose.yaml Dockerfile 如何解决此问题?

  • 我无法从外部访问我的服务。首先,这里是我的conf yaml文件: nginx-pod.yaml nginx-service.yaml metallb-config.yaml 然后我创建了集群。命令 打印: 一切正常,而且< code > ku bectl describe service/nginx-service 打印: curl命令在主服务器打印。接下来我试图从另一个网络打开,它不起作用,但

  • 我在同意的情况下为我的应用程序手动/php sdk创建了docusignjwt访问令牌,并在restapi的代码中使用了该访问令牌。访问令牌的到期时间为1小时。如何在不征求同意的情况下一次又一次地更新DocuSign jwt访问令牌?或者如何延长访问令牌的到期时间?