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

一个可让用户选择现有服务主体或注册新服务主体的控件。A control that lets users select an existing service principal or register a new one. 选择“新建”时,需执行注册新应用程序的步骤。When you select Create New , you go through 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 sample

默认视图取决于 defaultValue 属性中的值。The default view is determined by the values in the defaultValue property. 如果 principalId 属性包含有效的全局唯一标识符 (GUID),则此控件会搜索应用程序的对象 ID。If the principalId property contains a valid globally unique identifier (GUID), the control searches for the application's object ID. 如果用户没有从下拉列表中进行选择,则会应用默认值。The default value applies if the user doesn't make a selection from the dropdown.

Microsoft.Common.ServicePrincipalSelector 初始视图

从下拉列表中选择“新建”或现有应用程序标识符时,会显示“身份验证类型”,用于在文本框中输入密码或证书指纹。When you select Create new or an existing application identifier from the dropdown the Authentication Type is displayed to enter a password or certificate thumbprint in the text box.

Microsoft.Common.ServicePrincipalSelector 下拉列表选择

架构Schema

{
  "name": "ServicePrincipal",
  "type": "Microsoft.Common.ServicePrincipalSelector",
  "label": {
    "principalId": "App Id",
    "password": "Password",
    "certificateThumbprint": "Certificate thumbprint",
    "authenticationType": "Authentication Type",
    "sectionHeader": "Service Principal"
  },
  "toolTip": {
    "principalId": "App Id",
    "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:

    • name
    • type
    • label
    • defaultValue:指定默认的 principalIdnamedefaultValue: Specifies the default principalId and name.
  • 可选属性包括:The optional properties are:

    • 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": {
              "principalId": "App Id",
              "password": "Password",
              "certificateThumbprint": "Certificate thumbprint",
              "authenticationType": "Authentication Type",
              "sectionHeader": "Service Principal"
            },
            "toolTip": {
              "principalId": "App Id",
              "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 objectIds for the Service Principals configured for the selected application registration.

未从下拉列表中进行选择时,newOrExisting 属性值将为“new”:When no selection is made from the dropdown, 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 identifier is selected from the dropdown 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