Microsoft.Common.ServicePrincipalSelector UI 元素Microsoft.Common.ServicePrincipalSelector UI element

一个可让用户选择现有服务主体或注册新应用程序的控件。A control that lets users select an existing service principal or register a new application. 选择“新建”时,需执行注册新应用程序的步骤。When you select Create New, you follow the steps to register a new application. 选择现有应用程序时,此控件将提供一个文本框,用于输入密码或证书指纹。When you select an existing application, the control provides a textbox to input a password or certificate thumbprint.

UI 示例UI samples

可以使用默认应用程序、可以新建应用程序,还可以使用现有应用程序。You can use a default application, create a new application, or use an existing application.

使用默认应用程序或新建应用程序Use default application or create new

默认视图由 defaultValue 属性中的值确定,“服务主体类型”设置为“新建”。The default view is determined by the values in the defaultValue property and the Service Principal Type is set to Create New. 如果 principalId 属性包含有效的全局唯一标识符 (GUID),则此控件会搜索应用程序的 objectIdIf the principalId property contains a valid globally unique identifier (GUID), the control searches for the application's objectId. 如果用户没有从控件中进行选择,则会应用默认值。The default value applies if the user doesn't make a selection from the control.

若要注册新的应用程序,请选择“更改选择”,此时会显示“注册应用程序”对话框。If you want to register a new application, select Change selection and the Register an application dialog box is displayed. 输入 名称支持的帐户类型,然后选择“注册”按钮。Enter Name, Supported account type, and select the Register button.

Microsoft.Common.ServicePrincipalSelector 初始视图。

注册新应用程序后,请使用“身份验证类型”输入密码或证书指纹。After you register a new application, use the Authentication Type to enter a password or certificate thumbprint.

Microsoft.Common.ServicePrincipalSelector 身份验证。

使用现有应用程序Use existing application

若要使用现有应用程序,请选择“选择现有”,然后选择“进行选择”。To use an existing application, choose Select Existing and then select Make selection. 使用“选择应用程序”对话框搜索应用程序的名称。Use the Select an application dialog box to search for the application's name. 从结果中选择应用程序,然后单击“选择”按钮。From the results, select the the application and then the Select button. 选择应用程序后,控件会显示“身份验证类型”,此时可以输入密码或证书指纹。After you select an application, the control displays the Authentication Type to enter a password or certificate thumbprint.

Microsoft.Common.ServicePrincipalSelector 选择现有应用程序。

架构Schema

{
  "name": "ServicePrincipal",
  "type": "Microsoft.Common.ServicePrincipalSelector",
  "label": {
    "password": "Password",
    "certificateThumbprint": "Certificate thumbprint",
    "authenticationType": "Authentication Type",
    "sectionHeader": "Service Principal"
  },
  "toolTip": {
    "password": "Password",
    "certificateThumbprint": "Certificate thumbprint",
    "authenticationType": "Authentication Type"
  },
  "defaultValue": {
    "principalId": "<default guid>",
    "name": "(New) default App Id"
  },
  "constraints": {
    "required": true,
    "regex": "^[a-zA-Z0-9]{8,}$",
    "validationMessage": "Password must be at least 8 characters long, contain only numbers and letters"
  },
  "options": {
    "hideCertificate": false
  },
  "visible": true
}

备注Remarks

  • 必需的属性如下所示:The required properties are as follows:

    • name
    • type
    • label
    • defaultValue:指定默认的 principalIdnamedefaultValue: Specifies the default principalId and name.
  • 可选属性如下所示:The optional properties are as follows:

    • toolTip:将工具提示 infoBalloon 附加到每个标签。toolTip: Attaches a tooltip infoBalloon to each label.
    • visible:隐藏或显示控件。visible: Hide or display the control.
    • options:指定是否应使证书指纹选项可用。options: Specifies whether or not the certificate thumbprint option should be made available.
    • constraints:用于密码验证的正则表达式约束。constraints: Regex constraints for password validation.

示例Example

下面是 Microsoft.Common.ServicePrincipalSelector 控件的一个示例。The following is an example of the Microsoft.Common.ServicePrincipalSelector control. defaultValue 属性将 principalId 设置为 <default guid>(默认应用程序标识符 GUID 的占位符)。The defaultValue property sets principalId to <default guid> as a placeholder for a default application identifier GUID.

{
  "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
  "handler": "Microsoft.Azure.CreateUIDef",
  "version": "0.1.2-preview",
  "parameters": {
    "basics": [],
    "steps": [
      {
        "name": "SPNcontrol",
        "label": "SPNcontrol",
        "elements": [
          {
            "name": "ServicePrincipal",
            "type": "Microsoft.Common.ServicePrincipalSelector",
            "label": {
              "password": "Password",
              "certificateThumbprint": "Certificate thumbprint",
              "authenticationType": "Authentication Type",
              "sectionHeader": "Service Principal"
            },
            "toolTip": {
              "password": "Password",
              "certificateThumbprint": "Certificate thumbprint",
              "authenticationType": "Authentication Type"
            },
            "defaultValue": {
              "principalId": "<default guid>",
              "name": "(New) default App Id"
            },
            "constraints": {
              "required": true,
              "regex": "^[a-zA-Z0-9]{8,}$",
              "validationMessage": "Password must be at least 8 characters long, contain only numbers and letters"
            },
            "options": {
              "hideCertificate": false
            },
            "visible": true
          }
        ]
      }
    ],
    "outputs": {
      "appId": "[steps('SPNcontrol').ServicePrincipal.appId]",
      "objectId": "[steps('SPNcontrol').ServicePrincipal.objectId]",
      "password": "[steps('SPNcontrol').ServicePrincipal.password]",
      "certificateThumbprint": "[steps('SPNcontrol').ServicePrincipal.certificateThumbprint]",
      "newOrExisting": "[steps('SPNcontrol').ServicePrincipal.newOrExisting]",
      "authenticationType": "[steps('SPNcontrol').ServicePrincipal.authenticationType]"
    }
  }
}

示例输出Example output

appId 是所选的或所创建的应用程序注册的 ID。The appId is the Id of the application registration that you selected or created. objectId 是为所选应用程序注册配置的服务主体的 objectId 数组。The objectId is an array of object Ids for the service principals configured for the selected application registration.

未从控件中进行选择时,newOrExisting 属性值为“new”:When no selection is made from the control, the newOrExisting property value is new:

{
  "appId": {
    "value": "<default guid>"
  },
  "objectId": {
    "value": ["<default guid>"]
  },
  "password": {
    "value": "<password>"
  },
  "certificateThumbprint": {
    "value": ""
  },
  "newOrExisting": {
    "value": "new"
  },
  "authenticationType": {
    "value": "password"
  }
}

从控件中选择了“新建”或现有应用程序时,newOrExisting 属性值为“existing”:When Create new or an existing application is selected from the control the newOrExisting property value is existing:

{
  "appId": {
    "value": "<guid>"
  },
  "objectId": {
    "value": ["<guid>"]
  },
  "password": {
    "value": "<password>"
  },
  "certificateThumbprint": {
    "value": ""
  },
  "newOrExisting": {
    "value": "existing"
  },
  "authenticationType": {
    "value": "password"
  }
}

后续步骤Next steps