你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

更新服务主体凭据

本文介绍如何更新数据控制器中的机密。

例如,如果你:

  • 使用服务主体租户 ID、客户端 ID 和客户端机密的一组特定值部署了数据控制器
  • 更改其中的一个或多个值

你需要更新数据控制器中的机密。

背景

已根据创建服务主体中所述创建了服务主体。

步骤

  1. 在默认编辑器中访问服务主体机密。

    kubectl edit secret/upload-service-principal-secret -n <name of namespace>
    

    例如,若要在 arc 命名空间中编辑数据控制器的服务主体机密,请运行以下命令:

    kubectl edit secret/upload-service-principal-secret -n arc
    

    kubectl edit 命令在默认编辑器中打开凭据 .yml 文件。

  2. 编辑服务主体机密。

    在默认编辑器中,将 data 节中的值替换为已更新的凭据信息。

    例如:

    # Please edit the object below. Lines beginning with a '#' will be ignored,
    # and an empty file will abort the edit. If an error occurs while saving this file will be
    # reopened with the relevant failures.
    #
    apiVersion: v1
    data:
      authority: <authority id>
      clientId: <client id>
      clientSecret: <client secret>==
      tenantId: <tenant id>
    kind: Secret
    metadata:
      creationTimestamp: "2020-12-02T05:02:04Z"
      name: upload-service-principal-secret
      namespace: arc
      resourceVersion: "7235659"
      selfLink: /api/v1/namespaces/arc/secrets/upload-service-principal-secret
      uid: <globally unique identifier>
    type: Opaque
    

    根据需要编辑 clientIDclientSecret 和/或 tenantID 的值。

注意

值需要采用 base64 编码。 不要编辑任何其他属性。

如果为 clientIdclientSecrettenantID 提供了错误的值,则命令会在 control-xxxx Pod/控制器容器日志中返回如下所示的错误消息:

YYYY-MM-DD HH:MM:SS.mmmm | ERROR | [AzureUpload] Upload task exception: A configuration issue is preventing authentication - check the error message from the server for details.You can modify the configuration in the application registration portal. See https://aka.ms/msal-net-invalid-client for details. Original exception: AADSTS7000215: Invalid client secret is provided.