Azure Databricks - 需要在 CI/CD 过程中替换笔记本中的机密

Azure Databricks - Need to replace secrets in Notebook during CI/CD process

我有一个要求,我要从 Databricks 中基于密钥保管库的秘密范围获取秘密 Notebook.I 有开发和生产 Azure 资源的秘密,例如Data lake Gen2 的开发和生产实例。现在,我有一个 CI/CD 管道,它按原样部署 Notebook,从 dev 到生产 databricks 文件夹。

但是,我不知道如何在部署时替换笔记本中的秘密名称,以便开发中的数据块笔记本指向开发资源,生产中的秘密指向生产资源。为此,我需要覆盖 CI/CD 管道或其他一些设计中的秘密名称。

同样需要一个解决方案。感谢任何线索。

提前致谢

通常的方法是将机密范围名称作为笔记本的参数传递。为此,您需要创建一个 text widget that will be used to pass secret scope name, and just pass dev or prod scope name as a parameter for a job。它看起来像这样(在 Python 中):

# cell 1
dbutils.widgets.text("secret_scope", "", "Secret Scope")
# cell 2
secret_scope = dbutils.widgets.get("secret_scope")
# cell 3
my_secret = dbutils.secrets.get(secret_scope, "mySecret")