Grant Single Subscription Permissions
This guide is to be performed once per Azure Subscription.
The guide assumes that you have already created an Azure App Registration in your Azure Tenant.
If you haven't created an App Registration yet, please follow the Create a New Azure App Registration guide.
This guide will walk you through the process of granting permissions to your Azure Subscription for the Chronom App Registration you created.
Prerequisites
In order to grant permissions to the App Registration, you need to have:
- An Active Azure Subscription.
- An Azure App Registration with a client secret. Create a New Azure App Registration
- The ability to create a custom role in the subscription you want to scan.
- The ability to assign the custom role to the App Registration.
(Those abilities are usually granted by theOwner
role in the subscription)
Instructions
Create a Custom Role (Recommended)
If you want to grant Chronom the ability to perform a more in-depth scan of your Azure Subscription, you can create a custom role with the necessary permissions.
To create a custom role, follow these steps:
- Azure Portal
- Azure CLI (bash)
- Azure CLI (PowerShell)
-
Download the
Chronom Custom Role JSON
file by clicking here and saving it to your computer. -
Open the Azure Portal.
-
Navigate to the Azure Subscription you want to create the custom role in.
-
Click on the
Access Control (IAM)
blade. -
Click on the
+ Add
button and selectAdd custom role
. -
Fill in the following details:
- Baseline Permissions:
Start from JSON
- Upload the JSON file you downloaded in step 1.
- Click on the
Next
button.
- Baseline Permissions:
-
Review the permissions and click on the
Next
button.
If the permissions are too broad, you can remove the problematic permissions by clicking on the 🗑️ icon.
(Any of the permissions can be removed except for the*/read
permissions.)
In addition, you can exclude specific actions by clicking on the+ Exclude permissions
button. -
Under
Assignable scopes
clickAdd assignable scopes
, change the type toSubscription
and select the subscriptions you want to assign the role to.
Click on theSelect
button and then clickNext
. -
Review the role JSON and click on the
Review + create
button. If you prefer, you can modify the role permissions by clicking on theEdit
button.
(any of the permissions can be removed except for the*/read
permissions.) -
Review the role details and click on the
Create
button once you are ready.
All steps bellow should be executed in the same bash session.
It is recommended to copy and paste the commands one by one to avoid any mistakes.
The steps bellow assume you have Azure CLI installed and configured with the necessary permissions.
If you haven't installed Azure CLI yet, you can follow the instructions here.
-
If not already installed, install the
curl
andsed
packages according to your specific OS. -
Authenticate Azure CLI with the Tenant where your subscriptions are by running the following command:
az login
-
Configure the subscription you want to create the custom role in by running the following command:
⚠️ Replace<subscription-id>
with the ID of the subscription you want to create the custom role in.subscriptionId="<subscription-id>"
az account set --subscription $subscriptionId -
Download the
Chronom Custom Role JSON
file by running the following command:jsonFilePath="/tmp/chronom-custom-role-cli.json"
curl -o $jsonFilePath "https://docs.chronom.ai/assets/files/chronom-custom-role-cli.json"
sed -i "s/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/$subscriptionId/g" $jsonFilePath -
Create the custom role by running the following command:
az role definition create --role-definition @$jsonFilePath
The complete bash script
# Login to Azure CLI
az login
# Set the subscription
subscriptionId="<subscription-id>"
az account set --subscription $subscriptionId
# Download the Chronom Custom Role JSON file
jsonFilePath="/tmp/chronom-custom-role-cli.json"
curl -o $jsonFilePath "https://docs.chronom.ai/assets/files/chronom-custom-role-cli.json"
sed -i "s/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/$subscriptionId/g" $jsonFilePath
# Create the custom role
az role definition create --role-definition @$jsonFilePath
All steps bellow should be executed in the same PowerShell session.
It is recommended to copy and paste the commands one by one to avoid any mistakes.
The steps bellow assume you have Azure CLI installed and configured with the necessary permissions.
If you haven't installed Azure CLI yet, you can follow the instructions here.
-
Authenticate Azure CLI with the Tenant where your subscriptions are by running the following command:
az login
-
Configure the subscription you want to create the custom role in by running the following command:
⚠️ Replace<subscription-id>
with the ID of the subscription you want to create the custom role in.$subscriptionId="<subscription-id>"
az account set --subscription $subscriptionId -
Download the
Chronom Custom Role JSON
file by running the following command:$jsonFilePath="$env:USERPROFILE\Downloads\chronom-custom-role-cli.json"
Invoke-WebRequest -Uri "https://docs.chronom.ai/assets/files/chronom-custom-role-cli.json" -OutFile $jsonFilePath
(Get-Content $jsonFilePath) -replace "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", $subscriptionId | Set-Content $jsonFilePath -
Create the custom role by running the following command:
az role definition create --role-definition $jsonFilePath
The complete PowerShell script
# Login to Azure CLI
az login
# Set the subscription
$subscriptionId="<subscription-id>"
az account set --subscription $subscriptionId
# Download the Chronom Custom Role JSON file
$jsonFilePath="$env:USERPROFILE\Downloads\chronom-custom-role-cli.json"
Invoke-WebRequest -Uri "https://docs.chronom.ai/assets/files/chronom-custom-role-cli.json" -OutFile $jsonFilePath
(Get-Content $jsonFilePath) -replace "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", $subscriptionId | Set-Content $jsonFilePath
# Create the custom role
az role definition create --role-definition $jsonFilePath
Grant Permissions to the App Registration
To grant permissions to the App Registration, Follow these steps:
- Azure Portal
- Azure CLI (bash)
- Azure CLI (PowerShell)
-
Open the Azure Portal.
-
Navigate to the Azure Subscription you want to grant permissions to.
-
Click on the
Access Control (IAM)
blade. -
Click on the
+ Add
button and selectAdd role assignment
. -
Search for the Role that will be assigned to the App Registration.
If you created a custom role in the previous stage, search for the role name you created (Most likelyChronom Reader
), otherwise, search for theReader
role.
Select the role and click on theNext
button. -
Click on the
+ Select members
and search forChronom Read-Only App Registration
(or the name you gave to the App Registration).
Select the App Registration and click on theSelect
button then clickNext
. -
Click on the
Review + assign
button. -
On a new tab, navigate to Chronom's Integrations Page and click on the
+ Add a subscription under <Your Tenant Name>
button. -
Copy the
Subscription ID
and paste it in theSubscription ID
field on the Azure Portal, then select the rate of scans for the subscription and click on theSave
button.
All steps bellow should be executed in the same bash session.
It is recommended to copy and paste the commands one by one to avoid any mistakes.
The steps bellow assume you have Azure CLI installed and configured with the necessary permissions.
If you haven't installed Azure CLI yet, you can follow the instructions here.
-
Authenticate Azure CLI with the Tenant where your subscriptions are by running the following command:
az login
-
Configure the subscription you want to grant permissions to by running the following command:
⚠️ Replace<subscription-id>
with the ID of the subscription you want to grant permissions to.subscriptionId="<subscription-id>"
az account set --subscription $subscriptionId -
Get the App Registration's SP ID by running the following commands:
appName="Chronom Read-Only App Registration"
spId=$(az ad sp list --display-name "$appName" --query "[0].id" -o tsv) -
Confirm the App Registration's SP ID by running the following command: (Make sure the output contains the
appDisplayName
asChronom Read-Only App Registration
and thereplyUrls
ashttps://app.chronom.ai
)echo $spId
az ad sp show --id $spId -
Assign the role to the App Registration by running the following command:
⚠️ Replace<role-name>
with the name of the role you created in the previous step. (Most likelyChronom Reader
) (If you opted to use theReader
role, replace<role-name>
withReader
)roleName="<role-name>" # Replace with the role name you created / Reader
az role assignment create --role "$roleName" --assignee "$spId" --scope "/subscriptions/$subscriptionId" -
Navigate to Chronom's Integrations Page and click on the
+ Add a subscription under <Your Tenant Name>
button. -
Copy the
Subscription ID
and paste it in theSubscription ID
field on the Azure Portal, then select the rate of scans for the subscription and click on theSave
button.
The complete bash script
# Login to Azure CLI
az login
# Set the variables
subscriptionId="<subscription-id>"
appName="Chronom Read-Only App Registration"
roleName="Chronom Reader" # Replace with the role name you created / Reader
# Set the subscription
az account set --subscription $subscriptionId
# Get the App Registration's SP ID
spId=$(az ad sp list --display-name "$appName" --query "[0].id" -o tsv)
# Confirm the App Registration's SP ID
echo $spId
az ad sp show --id $spId
# Assign the role to the App Registration
az role assignment create --role "$roleName" --assignee "$spId" --scope "/subscriptions/$subscriptionId"
All steps bellow should be executed in the same PowerShell session.
It is recommended to copy and paste the commands one by one to avoid any mistakes.
The steps bellow assume you have Azure CLI installed and configured with the necessary permissions.
If you haven't installed Azure CLI yet, you can follow the instructions here.
-
Authenticate Azure CLI with the Tenant where your subscriptions are by running the following command:
az login
-
Configure the subscription you want to grant permissions to by running the following command:
⚠️ Replace<subscription-id>
with the ID of the subscription you want to grant permissions to.$subscriptionId="<subscription-id>"
az account set --subscription $subscriptionId -
Get the App Registration's SP ID by running the following commands:
$appName="Chronom Read-Only App Registration"
$spId=(az ad sp list --display-name $appName --query "[0].id" -o tsv) -
Confirm the App Registration's SP ID by running the following command:
(Make sure the output contains theappDisplayName
asChronom Read-Only App Registration
and thereplyUrls
ashttps://app.chronom.ai
)$spId
az ad sp show --id $spId -
Assign the role to the App Registration by running the following command:
⚠️ Replace<role-name>
with the name of the role you created in the previous step. (Most likelyChronom Reader
) (If you opted to use theReader
role, replace<role-name>
withReader
)$roleName="Chronom Reader" # Replace with the role name you created / Reader
az role assignment create --role $roleName --assignee $spId --scope "/subscriptions/$subscriptionId" -
Navigate to Chronom's Integrations Page and click on the
+ Add a subscription under <Your Tenant Name>
button. -
Copy the
Subscription ID
and paste it in theSubscription ID
field on the Azure Portal, then select the rate of scans for the subscription and click on theSave
button.
The complete PowerShell script
# Login to Azure CLI
az login
# Set the variables
$subscriptionId="<subscription-id>"
$appName="Chronom Read-Only App Registration"
$roleName="Chronom Reader" # Replace with the role name you created / Reader
# Set the subscription
az account set --subscription $subscriptionId
# Get the App Registration's SP ID
$spId=(az ad sp list --display-name $appName --query "[0].id" -o tsv)
# Confirm the App Registration's SP ID
$spId
az ad sp show --id $spId
# Assign the role to the App Registration
az role assignment create --role $roleName --assignee $spId --scope "/subscriptions/$subscriptionId"