Bagikan melalui


Role Assignments - Create

Membuat atau memperbarui penetapan peran berdasarkan cakupan dan nama.

PUT https://management.azure.com/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}?api-version=2022-04-01

Parameter URI

Nama Dalam Diperlukan Jenis Deskripsi
roleAssignmentName
path True

string

Nama penetapan peran. Ini bisa menjadi GUID yang valid.

scope
path True

string

Cakupan operasi atau sumber daya. Cakupan yang valid adalah: langganan (format: '/subscriptions/{subscriptionId}'), grup sumber daya (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', atau sumber daya (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'

api-version
query True

string

Versi API yang digunakan untuk operasi ini.

Isi Permintaan

Nama Diperlukan Jenis Deskripsi
properties.principalId True

string

ID utama.

properties.roleDefinitionId True

string

ID definisi peran.

properties.condition

string

Kondisi pada penetapan peran. Ini membatasi sumber daya yang dapat ditetapkan. misalnya: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'

properties.conditionVersion

string

Versi kondisi. Saat ini satu-satunya nilai yang diterima adalah '2.0'

properties.delegatedManagedIdentityResourceId

string

Id sumber daya identitas terkelola yang didelegasikan

properties.description

string

Deskripsi penetapan peran

properties.principalType

PrincipalType

Jenis utama ID utama yang ditetapkan.

Respons

Nama Jenis Deskripsi
200 OK

RoleAssignment

Mengembalikan penetapan peran.

201 Created

RoleAssignment

Mengembalikan penetapan peran.

Other Status Codes

ErrorResponse

Respons kesalahan yang menjelaskan mengapa operasi gagal.

Izin

Untuk memanggil API ini, Anda harus diberi peran yang memiliki izin berikut. Untuk informasi selengkapnya, lihat Peran bawaan Azure.

Microsoft.Authorization/roleAssignments/write

Keamanan

azure_auth

Alur OAuth2 Azure Active Directory

Jenis: oauth2
Alur: implicit
URL Otorisasi: https://login.microsoftonline.com/common/oauth2/authorize

Cakupan

Nama Deskripsi
user_impersonation meniru akun pengguna Anda

Contoh

Create role assignment for resource
Create role assignment for resource group
Create role assignment for subscription

Create role assignment for resource

Permintaan sampel

PUT https://management.azure.com/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff?api-version=2022-04-01

{
  "properties": {
    "roleDefinitionId": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
    "principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
    "principalType": "User"
  }
}

Respon sampel

{
  "properties": {
    "roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
    "principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
    "principalType": "User",
    "scope": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"
  },
  "id": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff",
  "type": "Microsoft.Authorization/roleAssignments",
  "name": "05c5a614-a7d6-4502-b150-c2fb455033ff"
}
{
  "properties": {
    "roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
    "principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
    "principalType": "User",
    "scope": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"
  },
  "id": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff",
  "type": "Microsoft.Authorization/roleAssignments",
  "name": "05c5a614-a7d6-4502-b150-c2fb455033ff"
}

Create role assignment for resource group

Permintaan sampel

PUT https://management.azure.com/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff?api-version=2022-04-01

{
  "properties": {
    "roleDefinitionId": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
    "principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
    "principalType": "User"
  }
}

Respon sampel

{
  "properties": {
    "roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
    "principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
    "principalType": "User",
    "scope": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg"
  },
  "id": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff",
  "type": "Microsoft.Authorization/roleAssignments",
  "name": "05c5a614-a7d6-4502-b150-c2fb455033ff"
}
{
  "properties": {
    "roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
    "principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
    "principalType": "User",
    "scope": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg"
  },
  "id": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff",
  "type": "Microsoft.Authorization/roleAssignments",
  "name": "05c5a614-a7d6-4502-b150-c2fb455033ff"
}

Create role assignment for subscription

Permintaan sampel

PUT https://management.azure.com/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff?api-version=2022-04-01

{
  "properties": {
    "roleDefinitionId": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
    "principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
    "principalType": "User"
  }
}

Respon sampel

{
  "properties": {
    "roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
    "principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
    "principalType": "User",
    "scope": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"
  },
  "id": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff",
  "type": "Microsoft.Authorization/roleAssignments",
  "name": "05c5a614-a7d6-4502-b150-c2fb455033ff"
}
{
  "properties": {
    "roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
    "principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
    "principalType": "User",
    "scope": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"
  },
  "id": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff",
  "type": "Microsoft.Authorization/roleAssignments",
  "name": "05c5a614-a7d6-4502-b150-c2fb455033ff"
}

Definisi

Nama Deskripsi
ErrorAdditionalInfo

Info tambahan kesalahan manajemen sumber daya.

ErrorDetail

Detail kesalahan.

ErrorResponse

Respons kesalahan

PrincipalType

Jenis utama ID utama yang ditetapkan.

RoleAssignment

Penetapan Peran

RoleAssignmentCreateParameters

Penetapan peran membuat parameter.

ErrorAdditionalInfo

Info tambahan kesalahan manajemen sumber daya.

Nama Jenis Deskripsi
info

object

Info tambahan.

type

string

Jenis info tambahan.

ErrorDetail

Detail kesalahan.

Nama Jenis Deskripsi
additionalInfo

ErrorAdditionalInfo[]

Info tambahan kesalahan.

code

string

Kode kesalahan.

details

ErrorDetail[]

Detail kesalahan.

message

string

Pesan kesalahan.

target

string

Target kesalahan.

ErrorResponse

Respons kesalahan

Nama Jenis Deskripsi
error

ErrorDetail

Objek kesalahan.

PrincipalType

Jenis utama ID utama yang ditetapkan.

Nama Jenis Deskripsi
Device

string

ForeignGroup

string

Group

string

ServicePrincipal

string

User

string

RoleAssignment

Penetapan Peran

Nama Jenis Nilai default Deskripsi
id

string

ID penetapan peran.

name

string

Nama penetapan peran.

properties.condition

string

Kondisi pada penetapan peran. Ini membatasi sumber daya yang dapat ditetapkan. misalnya: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'

properties.conditionVersion

string

Versi kondisi. Saat ini satu-satunya nilai yang diterima adalah '2.0'

properties.createdBy

string

Id pengguna yang membuat penugasan

properties.createdOn

string

Waktu pembuatannya

properties.delegatedManagedIdentityResourceId

string

Id sumber daya identitas terkelola yang didelegasikan

properties.description

string

Deskripsi penetapan peran

properties.principalId

string

ID utama.

properties.principalType

PrincipalType

User

Jenis utama ID utama yang ditetapkan.

properties.roleDefinitionId

string

ID definisi peran.

properties.scope

string

Cakupan penetapan peran.

properties.updatedBy

string

Id pengguna yang memperbarui penugasan

properties.updatedOn

string

Waktu pembaruan

type

string

Jenis penetapan peran.

RoleAssignmentCreateParameters

Penetapan peran membuat parameter.

Nama Jenis Nilai default Deskripsi
properties.condition

string

Kondisi pada penetapan peran. Ini membatasi sumber daya yang dapat ditetapkan. misalnya: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'

properties.conditionVersion

string

Versi kondisi. Saat ini satu-satunya nilai yang diterima adalah '2.0'

properties.createdBy

string

Id pengguna yang membuat penugasan

properties.createdOn

string

Waktu pembuatannya

properties.delegatedManagedIdentityResourceId

string

Id sumber daya identitas terkelola yang didelegasikan

properties.description

string

Deskripsi penetapan peran

properties.principalId

string

ID utama.

properties.principalType

PrincipalType

User

Jenis utama ID utama yang ditetapkan.

properties.roleDefinitionId

string

ID definisi peran.

properties.scope

string

Cakupan penetapan peran.

properties.updatedBy

string

Id pengguna yang memperbarui penugasan

properties.updatedOn

string

Waktu pembaruan