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

User - Create Or Update

创建或更新用户。

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}?api-version=2022-08-01
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}?notify={notify}&api-version=2022-08-01

URI 参数

名称 必需 类型 说明
resourceGroupName
path True

string

资源组的名称。 此名称不区分大小写。

serviceName
path True

string

API 管理服务的名称。

Regex pattern: ^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$

subscriptionId
path True

string

目标订阅的 ID。

userId
path True

string

用户标识符。 在当前API 管理服务实例中必须是唯一的。

api-version
query True

string

要用于此操作的 API 版本。

notify
query

boolean

向用户发送Email通知。

请求头

名称 必需 类型 说明
If-Match

string

实体的 ETag。 创建实体时不需要,但在更新实体时是必需的。

请求正文

名称 必需 类型 说明
properties.email True

string

电子邮件地址。 不得为空,且必须在服务实例中唯一。

properties.firstName True

string

名字。

properties.lastName True

string

姓氏。

properties.appType

AppType

确定发送创建用户请求的应用程序的类型。 默认为旧门户。

properties.confirmation

Confirmation

确定将发送给新创建的用户的确认电子邮件的类型。

properties.identities

UserIdentityContract[]

用户标识的集合。

properties.note

string

有关管理员设置的用户的可选备注。

properties.password

string

用户密码。 如果未提供任何值,则会生成默认密码。

properties.state

UserState

帐户状态。 指定用户是否处于活动状态。 被阻止的用户无法登录开发人员门户或调用已订阅产品的任何 API。 默认状态为“活动”。

响应

名称 类型 说明
200 OK

UserContract

已成功更新用户。

Headers

ETag: string

201 Created

UserContract

已成功创建用户。

Headers

ETag: string

Other Status Codes

ErrorResponse

描述操作失败原因的错误响应。

安全性

azure_auth

Azure Active Directory OAuth2 流。

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

名称 说明
user_impersonation 模拟用户帐户

示例

ApiManagementCreateUser

Sample Request

PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/5931a75ae4bbd512288c680b?api-version=2022-08-01

{
  "properties": {
    "firstName": "foo",
    "lastName": "bar",
    "email": "foobar@outlook.com",
    "confirmation": "signup"
  }
}

Sample Response

{
  "id": "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/5931a75ae4bbd512288c680b",
  "type": "Microsoft.ApiManagement/service/users",
  "name": "5931a75ae4bbd512288c680b",
  "properties": {
    "firstName": "foo",
    "lastName": "bar",
    "email": "foobar@outlook.com",
    "state": "active",
    "registrationDate": "2018-01-07T21:21:29.16Z",
    "groups": [],
    "identities": [
      {
        "provider": "Basic",
        "id": "foobar@outlook.com"
      }
    ]
  }
}
{
  "id": "/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/5931a75ae4bbd512288c680b",
  "type": "Microsoft.ApiManagement/service/users",
  "name": "5931a75ae4bbd512288c680b",
  "properties": {
    "firstName": "foo",
    "lastName": "bar",
    "email": "foobar@outlook.com",
    "state": "active",
    "registrationDate": "2018-01-07T21:21:29.16Z",
    "groups": [],
    "identities": [
      {
        "provider": "Basic",
        "id": "foobar@outlook.com"
      }
    ]
  }
}

定义

名称 说明
AppType

确定发送创建用户请求的应用程序的类型。 默认为旧门户。

Confirmation

确定将发送给新创建的用户的确认电子邮件的类型。

ErrorFieldContract

错误字段协定。

ErrorResponse

错误响应。

GroupContractProperties

组协定属性。

GroupType

组类型。

UserContract

用户详细信息。

UserCreateParameters

用户创建详细信息。

UserIdentityContract

用户标识详细信息。

UserState

帐户状态。 指定用户是否处于活动状态。 被阻止的用户无法登录开发人员门户或调用已订阅产品的任何 API。 默认状态为“活动”。

AppType

确定发送创建用户请求的应用程序的类型。 默认为旧门户。

名称 类型 说明
developerPortal

string

新开发人员门户发送了用户创建请求。

portal

string

用户创建请求由旧版开发人员门户发送。

Confirmation

确定将发送给新创建的用户的确认电子邮件的类型。

名称 类型 说明
invite

string

发送电子邮件,邀请用户注册并完成注册。

signup

string

向用户发送电子邮件,确认他们已成功注册。

ErrorFieldContract

错误字段协定。

名称 类型 说明
code

string

属性级错误代码。

message

string

属性级错误的可读表示形式。

target

string

属性名称。

ErrorResponse

错误响应。

名称 类型 说明
error.code

string

服务定义的错误代码。 此代码用作响应中指定的 HTTP 错误代码的子状态。

error.details

ErrorFieldContract[]

在发生验证错误时,请求中发送的无效字段列表。

error.message

string

错误的用户可读表示形式。

GroupContractProperties

组协定属性。

名称 类型 说明
builtIn

boolean

如果组是管理员、开发人员或来宾) (三个系统组之一,则为 true;否则为 false。

description

string

组说明。 可以包含采用 HTML 格式的标记。

displayName

string

组名称。

externalId

string

对于外部组,此属性包含来自外部标识提供者的组 ID,例如 Azure Active Directory aad://<tenant>.onmicrosoft.com/groups/<group object id>;否则值为 null。

type

GroupType

组类型。

GroupType

组类型。

名称 类型 说明
custom

string

external

string

system

string

UserContract

用户详细信息。

名称 类型 默认值 说明
id

string

资源的完全限定的资源 ID。 例如 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}

name

string

资源的名称

properties.email

string

电子邮件地址。

properties.firstName

string

名字。

properties.groups

GroupContractProperties[]

用户所属的组集合。

properties.identities

UserIdentityContract[]

用户标识的集合。

properties.lastName

string

姓氏。

properties.note

string

有关管理员设置的用户的可选备注。

properties.registrationDate

string

用户注册的日期。 日期符合以下格式: yyyy-MM-ddTHH:mm:ssZ 由 ISO 8601 标准指定。

properties.state

UserState

active

帐户状态。 指定用户是否处于活动状态。 被阻止的用户无法登录开发人员门户或调用已订阅产品的任何 API。 默认状态为“活动”。

type

string

资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”

UserCreateParameters

用户创建详细信息。

名称 类型 默认值 说明
properties.appType

AppType

确定发送创建用户请求的应用程序的类型。 默认为旧门户。

properties.confirmation

Confirmation

确定将发送给新创建的用户的确认电子邮件的类型。

properties.email

string

电子邮件地址。 不得为空,且必须在服务实例中唯一。

properties.firstName

string

名字。

properties.identities

UserIdentityContract[]

用户标识的集合。

properties.lastName

string

姓氏。

properties.note

string

有关管理员设置的用户的可选备注。

properties.password

string

用户密码。 如果未提供任何值,则会生成默认密码。

properties.state

UserState

active

帐户状态。 指定用户是否处于活动状态。 被阻止的用户无法登录开发人员门户或调用已订阅产品的任何 API。 默认状态为“活动”。

UserIdentityContract

用户标识详细信息。

名称 类型 说明
id

string

提供程序中的标识符值。

provider

string

标识提供者名称。

UserState

帐户状态。 指定用户是否处于活动状态。 被阻止的用户无法登录开发人员门户或调用已订阅产品的任何 API。 默认状态为“活动”。

名称 类型 说明
active

string

用户状态为活动状态。

blocked

string

用户被阻止。 被阻止的用户无法在开发人员门户或调用 API 进行身份验证。

deleted

string

用户帐户已关闭。 删除所有标识和相关实体。

pending

string

用户帐户处于挂起状态。 需要标识确认,然后才能激活它。