Not able to azure role definition template

Varma 1,390 Reputation points
2024-02-02T07:36:31.99+00:00

I have below template from MS. User's image

however when I try to update the resource , subscription and other details from current directory it is not allowing me to do so, Please see message below and suggest the fix User's image

and I am trying to use below commands to update $Content = Get-Content -Path $myRoleImageCreationPath -Raw
$Content = $Content -replace '<subscriptionID>', $subscriptionID
$Content = $Content -replace '<rgName>', $imageResourceGroup
$Content = $Content -replace 'Azure Image Builder Service Image Creation Role', $imageRoleDefName
$Content | Out-File -FilePath $myRoleImageCreationPath -Force Please suggest how can I proceed

Azure Role-based access control
Azure Role-based access control
An Azure service that provides fine-grained access management for Azure resources, enabling you to grant users only the rights they need to perform their jobs.
901 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Luis Arias 7,941 Reputation points
    2024-02-02T09:20:30.7766667+00:00

    Hi Varma, I try to replicate your error, however your command looks good, this is the code and files used: myRoleImageCreation.json

    {
        "Name": "Azure Image Builder Service Image Creation Role",
        "IsCustom": true,
        "Description": "Image builder access to create resources for the image build, you should delete or",
        "Actions": [
            "Microsoft.Compute/galleries/read",
            "Microsoft.Compute/galleries/images/read",
            "Microsoft.Compute/galleries/images/versions/read",
            "Microsoft.Compute/galleries/images/versions/write",
            "Microsoft.Compute/images/read",
            "Microsoft.Compute/images/read",
            "Microsoft.Compute/images/write"
        ],
        "NotActions": [],
        "AssignableScopes": [
            "/subscriptions/<subscriptionId>/resourceGroups/<rgName>"
        ]
    }
    
    

    Powershell used to update content:

    $myRoleImageCreationPath = "myRoleImageCreation.json"
    $Content = Get-Content -Path $myRoleImageCreationPath
    $subscriptionID = "MySusbcriptionID"
    $imageResourceGroup = "MyResourceGroupName"
    $imageRoleDefName = "MyRoleName"
    $Content = $Content -replace '<subscriptionID>', $subscriptionID
    $Content = $Content -replace '<rgName>', $imageResourceGroup
    $Content = $Content -replace 'Azure Image Builder Service Image Creation Role', $imageRoleDefName
    $Content | Out-File -FilePath $myRoleImageCreationPath -Force
    

    This is the output with the content updated:

    {
        "Name": "MyRoleName",
        "IsCustom": true,
        "Description": "Image builder access to create resources for the image build, you should delete or",
        "Actions": [
            "Microsoft.Compute/galleries/read",
            "Microsoft.Compute/galleries/images/read",
            "Microsoft.Compute/galleries/images/versions/read",
            "Microsoft.Compute/galleries/images/versions/write",
            "Microsoft.Compute/images/read",
            "Microsoft.Compute/images/read",
            "Microsoft.Compute/images/write"
        ],
        "NotActions": [],
        "AssignableScopes": [
            "/subscriptions/MySusbcriptionID/resourceGroups/MyResourceGroupName"
        ]
    }
    
    

    Let me know the error that you are getting from the file update in order to help you. Cheers Luis


    If the information helped address your question, please Accept the answer.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.