在 ADF 管道中使用 post 方法,在正文中我有喜欢
grant_type=client_credentials&client_id=xxxxxxxx&client_secret=xxxxxxxxx&resource=xxxxxxxxx.net
我必须创建一个秘密变量,以及如何传递秘密变量以及如何调试 ADF 中的管道。
请尽快分享答案。
我尝试添加一个秘密变量并将该变量传递到正文中,它会抛出错误,例如错误请求
要实现您的要求,首先您需要为其生成 Bearer 令牌。
创建应用程序注册和秘密。为该应用程序分配 Key Vault 管理员 角色,如下所示。
然后在 ADF 管道中的 Web 活动中提供以下配置。
URL : https://login.microsoftonline.com/<tenant-id>/oauth2/token
Body : grant_type=client_credentials&client_id=<your-app-client-id>&client_secret=<your-app-client-secret>&resource=https://vault.azure.net
Headers : Content-type application/x-www-form-urlencoded
这将生成所需的
access_token
。要更新机密值,首先您需要该机密的最新机密版本。为此,请使用具有以下配置的另一个网络活动。
URL - https://<keyvault_name>.vault.azure.net/secrets/<secret_name>/?api-version=7.0
Headers : Bearer @{activity('Web3').output.access_token}
这将在其 id 中提供 keyvault URL,其中包含当前密钥版本和当前密钥值。
现在,在另一个 Web 活动中使用此
id
作为 URL,并使用如下所示的 PUT 请求将变量传递到主体以更新秘密值。
URL : @concat(activity('Web1').output.id,'?api-version=7.4')
Body : @json(concat('{"value": "',variables('new_secret'),'", "contentType": "","attributes":{"enabled": true},"tags": {}}'))
调试管道,管道运行后,秘密值将从像我一样的设置变量中更新。