Role Assignments - Create

Skapa eller uppdatera en rolltilldelning efter omfång och namn.

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

URI-parametrar

Name I Obligatorisk Typ Description
roleAssignmentName
path True

string

Namnet på rolltilldelningen. Det kan vara valfritt giltigt GUID.

scope
path True

string

Åtgärdens eller resursens omfattning. Giltiga omfång är: prenumeration (format: '/subscriptions/{subscriptionId}'), resursgrupp (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', eller resurs (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'

api-version
query True

string

Den API-version som ska användas för den här åtgärden.

Begärandetext

Name Obligatorisk Typ Description
properties.principalId True

string

Huvudkonto-ID.

properties.roleDefinitionId True

string

Rolldefinitions-ID.

properties.condition

string

Villkoren för rolltilldelningen. Detta begränsar de resurser som den kan tilldelas till. t.ex. @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase "foo_storage_container"

properties.conditionVersion

string

Version av villkoret. För närvarande är det enda accepterade värdet "2.0"

properties.delegatedManagedIdentityResourceId

string

ID för den delegerade hanterade identitetsresursen

properties.description

string

Beskrivning av rolltilldelning

properties.principalType

PrincipalType

Huvudtypen för det tilldelade huvudkontots ID.

Svar

Name Typ Description
200 OK

RoleAssignment

Returnerar rolltilldelningen.

201 Created

RoleAssignment

Returnerar rolltilldelningen.

Other Status Codes

ErrorResponse

Felsvar som beskriver varför åtgärden misslyckades.

Behörigheter

För att anropa detta API måste du ha tilldelats en roll som har följande behörigheter. Mer information finns i Inbyggda roller i Azure.

Microsoft.Authorization/roleAssignments/write

Säkerhet

azure_auth

Azure Active Directory OAuth2 Flow

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

Scopes

Name Description
user_impersonation personifiera ditt användarkonto

Exempel

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

Create role assignment for resource

Sample Request

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"
  }
}

Sample Response

{
  "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

Sample Request

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"
  }
}

Sample Response

{
  "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

Sample Request

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"
  }
}

Sample Response

{
  "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"
}

Definitioner

Name Description
ErrorAdditionalInfo

Ytterligare information om resurshanteringsfelet.

ErrorDetail

Felinformationen.

ErrorResponse

Felsvar

PrincipalType

Huvudtypen för det tilldelade huvudkontots ID.

RoleAssignment

Rolltilldelningar

RoleAssignmentCreateParameters

Skapa parametrar för rolltilldelning.

ErrorAdditionalInfo

Ytterligare information om resurshanteringsfelet.

Name Typ Description
info

object

Den ytterligare informationen.

type

string

Ytterligare informationstyp.

ErrorDetail

Felinformationen.

Name Typ Description
additionalInfo

ErrorAdditionalInfo[]

Ytterligare information om felet.

code

string

Felkoden.

details

ErrorDetail[]

Felinformationen.

message

string

Felmeddelandet.

target

string

Felmålet.

ErrorResponse

Felsvar

Name Typ Description
error

ErrorDetail

Felobjektet.

PrincipalType

Huvudtypen för det tilldelade huvudkontots ID.

Name Typ Description
Device

string

ForeignGroup

string

Group

string

ServicePrincipal

string

User

string

RoleAssignment

Rolltilldelningar

Name Typ Standardvärde Description
id

string

Rolltilldelnings-ID.

name

string

Rolltilldelningens namn.

properties.condition

string

Villkoren för rolltilldelningen. Detta begränsar de resurser som den kan tilldelas till. t.ex. @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase "foo_storage_container"

properties.conditionVersion

string

Version av villkoret. För närvarande är det enda accepterade värdet "2.0"

properties.createdBy

string

ID för användaren som skapade tilldelningen

properties.createdOn

string

Tid då den skapades

properties.delegatedManagedIdentityResourceId

string

ID för den delegerade hanterade identitetsresursen

properties.description

string

Beskrivning av rolltilldelning

properties.principalId

string

Huvudkonto-ID.

properties.principalType

PrincipalType

User

Huvudtypen för det tilldelade huvudkontots ID.

properties.roleDefinitionId

string

Rolldefinitions-ID.

properties.scope

string

Rolltilldelningsomfånget.

properties.updatedBy

string

ID för användaren som uppdaterade tilldelningen

properties.updatedOn

string

Tid då den uppdaterades

type

string

Rolltilldelningstypen.

RoleAssignmentCreateParameters

Skapa parametrar för rolltilldelning.

Name Typ Standardvärde Description
properties.condition

string

Villkoren för rolltilldelningen. Detta begränsar de resurser som den kan tilldelas till. t.ex. @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase "foo_storage_container"

properties.conditionVersion

string

Version av villkoret. För närvarande är det enda accepterade värdet "2.0"

properties.createdBy

string

ID för användaren som skapade tilldelningen

properties.createdOn

string

Tid då den skapades

properties.delegatedManagedIdentityResourceId

string

ID för den delegerade hanterade identitetsresursen

properties.description

string

Beskrivning av rolltilldelning

properties.principalId

string

Huvudkonto-ID.

properties.principalType

PrincipalType

User

Huvudtypen för det tilldelade huvudkontots ID.

properties.roleDefinitionId

string

Rolldefinitions-ID.

properties.scope

string

Rolltilldelningsomfånget.

properties.updatedBy

string

ID för användaren som uppdaterade tilldelningen

properties.updatedOn

string

Tid då den uppdaterades