Kapsam ve ada göre rol ataması oluşturun veya güncelleştirin.
PUT https://management.azure.com/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}?api-version=2022-04-01
URI Parametreleri
| Name |
İçinde |
Gerekli |
Tür |
Description |
|
roleAssignmentName
|
path |
True
|
string
|
Rol atamasının adı. Herhangi bir geçerli GUID olabilir.
|
|
scope
|
path |
True
|
string
|
Kaynağın tam nitelikli Azure Resource manager tanımlayıcısı.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Bu işlem için kullanılacak API sürümü.
|
İstek Gövdesi
| Name |
Gerekli |
Tür |
Description |
|
properties.principalId
|
True
|
string
|
Asıl kimlik.
|
|
properties.roleDefinitionId
|
True
|
string
|
Rol tanımı kimliği.
|
|
properties.condition
|
|
string
|
Rol ataması koşulları. Bu, atanabilen kaynakları sınırlar. Örneğin: @Resource[Microsoft. Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'
|
|
properties.conditionVersion
|
|
string
|
Koşulun sürümü. Şu anda kabul edilen tek değer '2.0'
|
|
properties.delegatedManagedIdentityResourceId
|
|
string
|
Temsilci olarak atanan yönetilen kimlik kaynağının kimliği
|
|
properties.description
|
|
string
|
Rol atamasının açıklaması
|
|
properties.principalType
|
|
PrincipalType
|
Atanan asıl kimliğin asıl türü.
|
Yanıtlar
| Name |
Tür |
Description |
|
200 OK
|
RoleAssignment
|
Kaynak 'RoleAssignment' güncelleme işlemi başarılı oldu
|
|
201 Created
|
RoleAssignment
|
Resource 'RoleAssignment' işlemi başarılı oldu
|
|
Other Status Codes
|
ErrorResponse
|
Beklenmeyen bir hata yanıtı.
|
İzinler
Bu API’yi çağırmak için aşağıdaki izinlere sahip bir rol atanması gerekir. Daha fazla bilgi için bkz. Azure yerleşik rolleri.
Microsoft.Authorization/roleAssignments/write
Güvenlik
azure_auth
Azure Active Directory OAuth2 Akışı.
Tür:
oauth2
Akış:
implicit
Yetkilendirme URL’si:
https://login.microsoftonline.com/common/oauth2/authorize
Kapsamlar
| Name |
Description |
|
user_impersonation
|
kullanıcı hesabınızın kimliğine bürünme
|
Örnekler
Create role assignment for resource
Örnek isteği
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": {
"principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
"principalType": "User",
"roleDefinitionId": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.authorization import AuthorizationManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-authorization
# USAGE
python role_assignments_create_for_resource.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = AuthorizationManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.role_assignments.create(
scope="subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account",
role_assignment_name="05c5a614-a7d6-4502-b150-c2fb455033ff",
parameters={
"properties": {
"principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
"principalType": "User",
"roleDefinitionId": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
}
},
)
print(response)
# x-ms-original-file: 2022-04-01/RoleAssignments_CreateForResource.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armauthorization_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v3"
)
// Generated from example definition: 2022-04-01/RoleAssignments_CreateForResource.json
func ExampleRoleAssignmentsClient_Create_createRoleAssignmentForResource() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armauthorization.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewRoleAssignmentsClient().Create(ctx, "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account", "05c5a614-a7d6-4502-b150-c2fb455033ff", armauthorization.RoleAssignmentCreateParameters{
Properties: &armauthorization.RoleAssignmentProperties{
PrincipalID: to.Ptr("ce2ce14e-85d7-4629-bdbc-454d0519d987"),
PrincipalType: to.Ptr(armauthorization.PrincipalTypeUser),
RoleDefinitionID: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armauthorization.RoleAssignmentsClientCreateResponse{
// RoleAssignment: &armauthorization.RoleAssignment{
// Name: to.Ptr("05c5a614-a7d6-4502-b150-c2fb455033ff"),
// Type: to.Ptr("Microsoft.Authorization/roleAssignments"),
// ID: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff"),
// Properties: &armauthorization.RoleAssignmentProperties{
// PrincipalID: to.Ptr("ce2ce14e-85d7-4629-bdbc-454d0519d987"),
// PrincipalType: to.Ptr(armauthorization.PrincipalTypeUser),
// RoleDefinitionID: to.Ptr("/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"),
// Scope: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AuthorizationManagementClient } = require("@azure/arm-authorization");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update a role assignment by scope and name.
*
* @summary create or update a role assignment by scope and name.
* x-ms-original-file: 2022-04-01/RoleAssignments_CreateForResource.json
*/
async function createRoleAssignmentForResource() {
const credential = new DefaultAzureCredential();
const client = new AuthorizationManagementClient(credential);
const result = await client.roleAssignments.create(
"subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account",
"05c5a614-a7d6-4502-b150-c2fb455033ff",
{
principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987",
principalType: "User",
roleDefinitionId:
"/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Örnek yanıt
{
"name": "05c5a614-a7d6-4502-b150-c2fb455033ff",
"type": "Microsoft.Authorization/roleAssignments",
"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",
"properties": {
"principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
"principalType": "User",
"roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
"scope": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"
}
}
{
"name": "05c5a614-a7d6-4502-b150-c2fb455033ff",
"type": "Microsoft.Authorization/roleAssignments",
"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",
"properties": {
"principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
"principalType": "User",
"roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
"scope": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"
}
}
Create role assignment for resource group
Örnek isteği
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": {
"principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
"principalType": "User",
"roleDefinitionId": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.authorization import AuthorizationManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-authorization
# USAGE
python role_assignments_create_for_resource_group.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = AuthorizationManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.role_assignments.create(
scope="subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg",
role_assignment_name="05c5a614-a7d6-4502-b150-c2fb455033ff",
parameters={
"properties": {
"principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
"principalType": "User",
"roleDefinitionId": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
}
},
)
print(response)
# x-ms-original-file: 2022-04-01/RoleAssignments_CreateForResourceGroup.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armauthorization_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v3"
)
// Generated from example definition: 2022-04-01/RoleAssignments_CreateForResourceGroup.json
func ExampleRoleAssignmentsClient_Create_createRoleAssignmentForResourceGroup() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armauthorization.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewRoleAssignmentsClient().Create(ctx, "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg", "05c5a614-a7d6-4502-b150-c2fb455033ff", armauthorization.RoleAssignmentCreateParameters{
Properties: &armauthorization.RoleAssignmentProperties{
PrincipalID: to.Ptr("ce2ce14e-85d7-4629-bdbc-454d0519d987"),
PrincipalType: to.Ptr(armauthorization.PrincipalTypeUser),
RoleDefinitionID: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armauthorization.RoleAssignmentsClientCreateResponse{
// RoleAssignment: &armauthorization.RoleAssignment{
// Name: to.Ptr("05c5a614-a7d6-4502-b150-c2fb455033ff"),
// Type: to.Ptr("Microsoft.Authorization/roleAssignments"),
// ID: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff"),
// Properties: &armauthorization.RoleAssignmentProperties{
// PrincipalID: to.Ptr("ce2ce14e-85d7-4629-bdbc-454d0519d987"),
// PrincipalType: to.Ptr(armauthorization.PrincipalTypeUser),
// RoleDefinitionID: to.Ptr("/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"),
// Scope: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AuthorizationManagementClient } = require("@azure/arm-authorization");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update a role assignment by scope and name.
*
* @summary create or update a role assignment by scope and name.
* x-ms-original-file: 2022-04-01/RoleAssignments_CreateForResourceGroup.json
*/
async function createRoleAssignmentForResourceGroup() {
const credential = new DefaultAzureCredential();
const client = new AuthorizationManagementClient(credential);
const result = await client.roleAssignments.create(
"subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg",
"05c5a614-a7d6-4502-b150-c2fb455033ff",
{
principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987",
principalType: "User",
roleDefinitionId:
"/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Örnek yanıt
{
"name": "05c5a614-a7d6-4502-b150-c2fb455033ff",
"type": "Microsoft.Authorization/roleAssignments",
"id": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff",
"properties": {
"principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
"principalType": "User",
"roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
"scope": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg"
}
}
{
"name": "05c5a614-a7d6-4502-b150-c2fb455033ff",
"type": "Microsoft.Authorization/roleAssignments",
"id": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff",
"properties": {
"principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
"principalType": "User",
"roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
"scope": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg"
}
}
Create role assignment for subscription
Örnek isteği
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": {
"principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
"principalType": "User",
"roleDefinitionId": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.authorization import AuthorizationManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-authorization
# USAGE
python role_assignments_create_for_subscription.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = AuthorizationManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.role_assignments.create(
scope="subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2",
role_assignment_name="05c5a614-a7d6-4502-b150-c2fb455033ff",
parameters={
"properties": {
"principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
"principalType": "User",
"roleDefinitionId": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
}
},
)
print(response)
# x-ms-original-file: 2022-04-01/RoleAssignments_CreateForSubscription.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armauthorization_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v3"
)
// Generated from example definition: 2022-04-01/RoleAssignments_CreateForSubscription.json
func ExampleRoleAssignmentsClient_Create_createRoleAssignmentForSubscription() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armauthorization.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewRoleAssignmentsClient().Create(ctx, "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2", "05c5a614-a7d6-4502-b150-c2fb455033ff", armauthorization.RoleAssignmentCreateParameters{
Properties: &armauthorization.RoleAssignmentProperties{
PrincipalID: to.Ptr("ce2ce14e-85d7-4629-bdbc-454d0519d987"),
PrincipalType: to.Ptr(armauthorization.PrincipalTypeUser),
RoleDefinitionID: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armauthorization.RoleAssignmentsClientCreateResponse{
// RoleAssignment: &armauthorization.RoleAssignment{
// Name: to.Ptr("05c5a614-a7d6-4502-b150-c2fb455033ff"),
// Type: to.Ptr("Microsoft.Authorization/roleAssignments"),
// ID: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff"),
// Properties: &armauthorization.RoleAssignmentProperties{
// PrincipalID: to.Ptr("ce2ce14e-85d7-4629-bdbc-454d0519d987"),
// PrincipalType: to.Ptr(armauthorization.PrincipalTypeUser),
// RoleDefinitionID: to.Ptr("/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"),
// Scope: to.Ptr("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AuthorizationManagementClient } = require("@azure/arm-authorization");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update a role assignment by scope and name.
*
* @summary create or update a role assignment by scope and name.
* x-ms-original-file: 2022-04-01/RoleAssignments_CreateForSubscription.json
*/
async function createRoleAssignmentForSubscription() {
const credential = new DefaultAzureCredential();
const client = new AuthorizationManagementClient(credential);
const result = await client.roleAssignments.create(
"subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2",
"05c5a614-a7d6-4502-b150-c2fb455033ff",
{
principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987",
principalType: "User",
roleDefinitionId:
"/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Örnek yanıt
{
"name": "05c5a614-a7d6-4502-b150-c2fb455033ff",
"type": "Microsoft.Authorization/roleAssignments",
"id": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff",
"properties": {
"principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
"principalType": "User",
"roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
"scope": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"
}
}
{
"name": "05c5a614-a7d6-4502-b150-c2fb455033ff",
"type": "Microsoft.Authorization/roleAssignments",
"id": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/05c5a614-a7d6-4502-b150-c2fb455033ff",
"properties": {
"principalId": "ce2ce14e-85d7-4629-bdbc-454d0519d987",
"principalType": "User",
"roleDefinitionId": "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d",
"scope": "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"
}
}
Tanımlar
createdByType
Numaralandırma
Kaynağı oluşturan kimliğin türü.
| Değer |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Nesne
Kaynak yönetimi hatası ek bilgileri.
| Name |
Tür |
Description |
|
info
|
object
|
Ek bilgiler.
|
|
type
|
string
|
Ek bilgi türü.
|
ErrorDetail
Nesne
Hata ayrıntısı.
| Name |
Tür |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
Hata ek bilgileri.
|
|
code
|
string
|
Hata kodu.
|
|
details
|
ErrorDetail[]
|
Hata ayrıntıları.
|
|
message
|
string
|
Hata iletisi.
|
|
target
|
string
|
Hata hedefi.
|
ErrorResponse
Nesne
Hata yanıtı
PrincipalType
Numaralandırma
Atanan asıl kimliğin asıl türü.
| Değer |
Description |
|
User
|
User
|
|
Group
|
Grup
|
|
ServicePrincipal
|
Hizmet İlkesi (ServicePrincipal)
|
|
ForeignGroup
|
ForeignGroup
|
|
Device
|
Cihaz
|
|
AgentUser
|
Bir kullanıcıdan türetilen ajan kimliği.
|
|
AgentServicePrincipal
|
Bir hizmet prensibinden türetilen ajan kimliği.
|
RoleAssignment
Nesne
Rol Atamaları
| Name |
Tür |
Default value |
Description |
|
id
|
string
|
|
Kaynağın tam kaynak kimliği. Örn - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
name
|
string
|
|
Kaynağın adı
|
|
properties.condition
|
string
|
|
Rol ataması koşulları. Bu, atanabilen kaynakları sınırlar. Örneğin: @Resource[Microsoft. Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'
|
|
properties.conditionVersion
|
string
|
|
Koşulun sürümü. Şu anda kabul edilen tek değer '2.0'
|
|
properties.createdBy
|
string
|
|
Atamayı oluşturan kullanıcının kimliği
|
|
properties.createdOn
|
string
(date-time)
|
|
Oluşturulduğu zaman
|
|
properties.delegatedManagedIdentityResourceId
|
string
|
|
Temsilci olarak atanan yönetilen kimlik kaynağının kimliği
|
|
properties.description
|
string
|
|
Rol atamasının açıklaması
|
|
properties.principalId
|
string
|
|
Asıl kimlik.
|
|
properties.principalType
|
PrincipalType
|
User
|
Atanan asıl kimliğin asıl türü.
|
|
properties.roleDefinitionId
|
string
|
|
Rol tanımı kimliği.
|
|
properties.scope
|
string
|
|
Rol atama kapsamı.
|
|
properties.updatedBy
|
string
|
|
Atamayı güncelleştiren kullanıcının kimliği
|
|
properties.updatedOn
|
string
(date-time)
|
|
Güncelleştirilen zaman
|
|
systemData
|
systemData
|
|
Azure Resource Manager metadata içeren createdBy ve modifiedBy bilgileri.
|
|
type
|
string
|
|
Kaynağın türü. Örneğin "Microsoft. Compute/virtualMachines" veya "Microsoft. Depo/Depolama Hesapları"
|
RoleAssignmentCreateParameters
Nesne
Rol ataması parametreleri oluşturur.
| Name |
Tür |
Default value |
Description |
|
properties.condition
|
string
|
|
Rol ataması koşulları. Bu, atanabilen kaynakları sınırlar. Örneğin: @Resource[Microsoft. Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'
|
|
properties.conditionVersion
|
string
|
|
Koşulun sürümü. Şu anda kabul edilen tek değer '2.0'
|
|
properties.createdBy
|
string
|
|
Atamayı oluşturan kullanıcının kimliği
|
|
properties.createdOn
|
string
(date-time)
|
|
Oluşturulduğu zaman
|
|
properties.delegatedManagedIdentityResourceId
|
string
|
|
Temsilci olarak atanan yönetilen kimlik kaynağının kimliği
|
|
properties.description
|
string
|
|
Rol atamasının açıklaması
|
|
properties.principalId
|
string
|
|
Asıl kimlik.
|
|
properties.principalType
|
PrincipalType
|
User
|
Atanan asıl kimliğin asıl türü.
|
|
properties.roleDefinitionId
|
string
|
|
Rol tanımı kimliği.
|
|
properties.scope
|
string
|
|
Rol atama kapsamı.
|
|
properties.updatedBy
|
string
|
|
Atamayı güncelleştiren kullanıcının kimliği
|
|
properties.updatedOn
|
string
(date-time)
|
|
Güncelleştirilen zaman
|
systemData
Nesne
Kaynağın oluşturulması ve son değiştirilmesiyle ilgili meta veriler.
| Name |
Tür |
Description |
|
createdAt
|
string
(date-time)
|
Kaynak oluşturma (UTC) zaman damgası.
|
|
createdBy
|
string
|
Kaynağı oluşturan kimlik.
|
|
createdByType
|
createdByType
|
Kaynağı oluşturan kimliğin türü.
|
|
lastModifiedAt
|
string
(date-time)
|
Kaynağın son değişikliğinin zaman damgası (UTC)
|
|
lastModifiedBy
|
string
|
Kaynağı en son değiştiren kimlik.
|
|
lastModifiedByType
|
createdByType
|
Kaynağı en son değiştiren kimlik türü.
|