Microsoft.Compute.CredentialsCombo UI 元素

CredentialsCombo 元素是一個控制項群組,包含針對 Windows 密碼、Linux 密碼或 SSH 公開金鑰的內建驗證。

UI 範例

針對 Windows,將會顯示密碼控制項。

Screenshot of the credentials combo user-interface element for a Windows password.

針對已選取 [密碼] 的 Linux,將會顯示密碼控制項:

Screenshot of the credentials combo user-interface element for a Linux password.

針對已選取 [SSH 公開金鑰] 的 Linux,將會顯示 SSH 金鑰控制項:

Screenshot of the credentials combo user-interface element for a Linux SSH public key.

SSH 公開金鑰來源有三個選項:

  • 產生新的金鑰組:提供名稱以在 Azure 中建立新的 SSH 金鑰組。
  • 使用儲存在 Azure 中的現有金鑰:選取儲存在 Azure 中的現有 SSH 公開金鑰。
  • 使用現有的公開金鑰:使用您已建立的 SSH 公開金鑰。 例如,在本機電腦上建立的 SSH 公開金鑰。

Screenshot of the credentials combo user-interface element with options for Linux SSH public key.

針對 [產生新的金鑰組] 選項,當您選取 [建立] 和 [下載私密金鑰並建立資源] 之後,系統就會在 [檢閱+建立] 索引標籤上產生金鑰。

Screenshot to generate new SSH key pair, and select download private key and create resource.

結構描述

針對 Windows,請使用下列結構描述:

{
  "name": "element1",
  "type": "Microsoft.Compute.CredentialsCombo",
  "label": {
    "password": "Password",
    "confirmPassword": "Confirm password"
  },
  "toolTip": {
    "password": ""
  },
  "constraints": {
    "required": true,
    "customPasswordRegex": "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{12,}$",
    "customValidationMessage": "The password must be alphanumeric, contain at least 12 characters, and have at least 1 letter and 1 number."
  },
  "options": {
    "hideConfirmation": false
  },
  "osPlatform": "Windows",
  "visible": true
}

針對 Linux,請使用下列結構描述:

{
  "name": "element1",
  "type": "Microsoft.Compute.CredentialsCombo",
  "label": {
    "authenticationType": "Authentication type",
    "password": "Password",
    "confirmPassword": "Confirm password",
    "sshPublicKey": "SSH public key"
  },
  "toolTip": {
    "authenticationType": "",
    "password": "",
    "sshPublicKey": ""
  },
  "constraints": {
    "required": true,
    "customPasswordRegex": "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{12,}$",
    "customValidationMessage": "The password must be alphanumeric, contain at least 12 characters, and have at least 1 letter and 1 number."
  },
  "options": {
    "hideConfirmation": false,
    "hidePassword": false
  },
  "osPlatform": "Linux",
  "visible": true
}

範例輸出

如果 osPlatformWindows,或 osPlatformLinux,而且使用者提供了密碼而不是 SSH 公開金鑰,則控制項會傳回下列輸出︰

{
  "authenticationType": "password",
  "password": "p4ssw0rddem0",
}

如果 osPlatformLinux 而且使用者提供了 SSH 公開金鑰,則控制項會傳回下列輸出︰

{
  "authenticationType": "sshPublicKey",
  "sshPublicKey": "AAAAB3NzaC1yc2EAAAABIwAAAIEA1on8gxCGJJWSRT4uOrR13mUaUk0hRf4RzxSZ1zRbYYFw8pfGesIFoEuVth4HKyF8k1y4mRUnYHP1XNMNMJl1JcEArC2asV8sHf6zSPVffozZ5TT4SfsUu/iKy9lUcCfXzwre4WWZSXXcPff+EHtWshahu3WzBdnGxm5Xoi89zcE=",
  "sshKeyName": "demo-public-key-name",
  "generateNewSshKey": false
}
  • 選取 [產生新的金鑰組] 時,sshPublicKey 屬性為空白。 原因是當您選取 [建立] 和 [下載私密金鑰並建立資源] 之後,系統才會在 [檢閱+建立] 索引標籤上產生金鑰。
  • 只有在 Azure 中產生的新 SSH 金鑰組,或已儲存在 Azure 中的金鑰,屬性 sshKeyName 才會包含名稱。
  • 當您使用現有的金鑰時,generateNewSshKeyfalse。 產生新的金鑰組時,此值為 true

備註

  • 必須指定 osPlatform,且可以是 WindowsLinux
  • 如果將 constraints.required 設為 true,則密碼或 SSH 公開金鑰文字方塊必須具有值,才能順利通過驗證。 預設值為 true
  • 如果將 options.hideConfirmation 設為 true,就會將確認使用者密碼的第二個文字方塊加以隱藏。 預設值為 false
  • 如果將 options.hidePassword 設為 true,就會將使用密碼驗證的選項加以隱藏。 只有在 osPlatformLinux 時才可以使用。 預設值為 false
  • 您可使用 customPasswordRegex 屬性針對允許密碼加上更多條件約束。 密碼無法自訂驗證時,就會顯示 customValidationMessage 中的字串。 這兩個屬性的預設值是 null。 結構描述會顯示每個屬性的範例。

下一步