> For the complete documentation index, see [llms.txt](https://doc.duaer.com/zh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/zh/integrations/builtin/credentials/azurestorage.md).

# 在 Duaer 里配置 Azure Storage 凭证

在 Duaer 中保存 Azure Storage 的连接信息，供工作流程节点在运行时使用。密钥经实例加密密钥保护，不会写进节点参数。
## 选 Azure Storage 凭证类型 <a href="#choose-a-credential-type" id="choose-a-credential-type"></a>

Duaer 的 Azure Storage 节点支持两种凭证：

- Azure Storage Shared Key API：在 Azure 门户打开存储账户的 Access keys，Account 填存储账户名，Key 填 key1。Azure Cloud 按所在云选择。
- Azure Storage OAuth2 API：在 Microsoft Entra 里注册应用，把 Duaer 的 OAuth 重定向地址加为 Web 平台的 Redirect URI，并给你的账号分配存储账户上的 Storage Blob Data Contributor 这类数据角色。Authentication 选 Client Secret 时填密钥；选 Certificate 时填证书和对应私钥。Account 填存储账户名，再点「连接我的账号」。

Azure Cloud 选 Custom 时要填 Endpoint，主机名里必须包含账户名，而且实例管理员要设置 DUAER_AZURE_STORAGE_CUSTOM_ENDPOINTS_ENABLED=true。

## Azure Storage OAuth2 API <a href="#azure-storage-oauth2-api" id="azure-storage-oauth2-api"></a>

在 Duaer 里新建 Azure Storage OAuth2 API 凭证，填写这些字段：

- Authorization URL：已预填。
- Access Token URL：默认 https://login.microsoftonline.com/common/oauth2/v2.0/token。
- Client ID（必填）
- Authentication：Duaer 换取和刷新令牌时向 Microsoft Entra 认证的方式。Certificate 用证书签名客户端断言（private_key_jwt），不发送客户端密码。默认 Client Secret，可选 Client Secret、Certificate。
- Client Secret（必填，密钥）：Authentication 为 Client Secret 时显示。
- Private Key（必填，密钥）：与上传到 Entra 应用注册的证书配对的 PEM 格式 RSA 私钥。用多行编辑器，按标准 PEM 格式填写：-----BEGIN PRIVATE KEY----- 密钥内容 -----END PRIVATE KEY-----。Authentication 为 Certificate 时显示。
- Certificate（必填，密钥）：登记在 Entra 应用注册（Certificates & secrets）上的 PEM 格式公钥证书。用来计算 x5t 指纹，告诉 Entra 用哪把密钥校验断言。Authentication 为 Certificate 时显示。
- Account
- Custom Scopes：自定义授权范围。默认关闭。
- Enabled Scopes：要启用的授权范围。默认 https://storage.azure.com/.default，Custom Scopes 打开时显示。

Duaer 对这种类型固定使用 OAuth2 Authorization Code（授权码） 授权方式。

在服务商的应用设置里登记 Duaer 凭证窗口显示的 OAuth 重定向地址（https://<你的 Duaer 地址>/rest/oauth2-credential/callback），再在 Duaer 里点「连接我的账号」并同意授权。

Duaer 默认申请的授权范围：https://storage.azure.com/.default。

所有 Duaer OAuth2 凭证共有的可选设置：Ignore SSL Issues (Insecure)、Token Expired Status Code、Encrypted Tokens (JWE)、JWKS URI。说明见 [OAuth2 API](/zh/integrations/builtin/credentials/httprequest.md#oauth2-api)。

使用它的 Duaer 节点：[Azure Storage](/zh/integrations/builtin/app-nodes/duaer-nodes-base.azurestorage.md)。

## Azure Storage Shared Key API <a href="#azure-storage-shared-key-api" id="azure-storage-shared-key-api"></a>

在 Duaer 里新建 Azure Storage Shared Key API 凭证，填写这些字段：

- Account：账户名。
- Key（密钥）：账户密钥。
- Azure Cloud：默认 Azure Public Cloud，可选 Azure Public Cloud、Azure US Government、Azure China、Custom。
- Endpoint（必填）：存储终端的 https:// 地址，主机名里必须包含账户名。实例管理员要在这台 Duaer 上设置 DUAER_AZURE_STORAGE_CUSTOM_ENDPOINTS_ENABLED=true。账户名在路径里的终端（例如 Azurite）不能用。Azure Cloud 为 Custom 时显示。

保存时，Duaer 会用这些值测试一次连接。

使用它的 Duaer 节点：[Azure Storage](/zh/integrations/builtin/app-nodes/duaer-nodes-base.azurestorage.md)。

## 在 Duaer 里保存连接

打开 Credentials，创建 Azure Storage。按字段填写密钥、OAuth 或服务器地址。保存后，工作流程节点引用这份凭证，而不是把密钥写进参数。

凭证内容经实例的加密密钥保护。换密钥或弄丢密钥后，已存凭证会解不开，见托管文档里的加密密钥说明。对应节点见 [相关节点](/zh/integrations/builtin/app-nodes/duaer-nodes-base.azurestorage.md)。

## 谁能用这份凭证

能否看到或编辑，取决于项目和角色。不要把密钥贴进聊天或变量。外部密钥库见外部密钥文档。
## Questions

### Duaer 的 Azure Storage 凭证密钥会出现在节点参数里吗？

不会。在 Duaer 里，Azure Storage 的密钥保存在凭证中，节点只引用凭证。执行记录也不应出现明文密钥。

### 在 Duaer 里 Azure Storage 凭证保存失败常见原因是什么？

字段填错、OAuth 回调地址与实例 URL 不一致，或当前角色不能创建凭证。先核对 Azure Storage 服务商要求的字段，再确认你在该项目里有权新建凭证。

