A powerful CLI tool for creating and managing Azure custom roles
Project description
Azure Custom Role Designer
A powerful CLI tool for platform engineers to create, update, and manage Azure custom roles with granular control over permissions.
Features
- Create roles from scratch - Start with an empty role definition
- Cherry-pick permissions - Select specific permissions from existing roles
- Merge permissions - Combine permissions from one or more existing roles with filtering capabilities
- Remove permissions - Filter and exclude specific permissions with advanced filtering
- Filter by string - Search permissions by action name pattern
- Filter by type - Separate control and data plane permissions
- Persist roles - Save and load role definitions locally and to Azure
Installation
Option 1: Install from the repository (Recommended)
# Clone/navigate to the project
cd azure-custom-role-tool
# Install in development mode
pip install -e .
# Or install normally
pip install .
Option 2: Install with all dependencies
pip install azure-custom-role-tool
Option 3: Install from source with all requirements
git clone <repo-url>
cd azure-custom-role-tool
pip install .
Quick Start
Using the installed command
# Check version
azure-custom-role-tool --version
# Interactive mode
azure-custom-role-tool
# Or use specific commands
azure-custom-role-tool create --name "My Custom Role" --description "Custom role for my team"
azure-custom-role-tool merge --roles "devops-developer,reader" --filter "Storage"
azure-custom-role-tool remove --filter "Delete"
Using the module directly
# Check version
python -m azure_custom_role_tool --version
# Run as module
python -m azure_custom_role_tool
# Or use the module in your Python code
from azure_custom_role_tool import RoleManager, PermissionFilter, __version__
print(f"Using Azure Custom Role Tool v{__version__}")
manager = RoleManager()
role = manager.create_role("MyRole", "My custom role")
Usage
Interactive Mode
Run the tool without arguments or use the console command to enter console mode:
azure-custom-role-tool console
This launches an interactive menu where you can:
- Create a new role
- Load an existing role
- Merge permissions
- Remove permissions
- Filter and view permissions
- Save/publish the role
Interactive Features:
- Command History: Use arrow keys (↑/↓) to navigate through previous commands
- Persistent History: Command history is saved to
~/.azure-custom-role-tool-historyand persists across sessions - Context Help: Type
help <command>to see detailed help for any command - State Preservation: The current role remains loaded across multiple commands within the session
Command Line Mode
# Create a new role
azure-custom-role-tool create --name "Name" --description "Description" --subscription-id xx-xx-xx
# Start from existing role
azure-custom-role-tool load --name "existing-role"
# Merge multiple roles
azure-custom-role-tool merge --roles role1,role2,role3 --filter "Storage" --filter-type control
# Remove permissions
azure-custom-role-tool remove --filter "*/Delete/*" --filter-type data
# List available roles
azure-custom-role-tool list
# View role details
azure-custom-role-tool view --name "role-name"
# Save role locally
azure-custom-role-tool save --name "role-name" --output roles/my-role.json
# Publish to Azure
azure-custom-role-tool publish --name "role-name"
Configuration
Create a .env file for Azure authentication:
AZURE_SUBSCRIPTION_ID=your-subscription-id
AZURE_TENANT_ID=your-tenant-id
AZURE_CLIENT_ID=your-client-id
AZURE_CLIENT_SECRET=your-client-secret
Or use Azure CLI authentication (default).
File Structure
azure-custom-role-tool/
├── custom_role_designer.py # Main CLI tool
├── role_manager.py # Role management logic
├── permission_filter.py # Filtering and search
├── azure_client.py # Azure SDK integration
├── requirements.txt # Dependencies
├── roles/ # Local role definitions
├── examples/ # Example role definitions
└── tests/ # Unit tests
Architecture
Role Definition Schema
Roles are stored as JSON files conforming to Azure custom role definition format:
{
"Name": "Custom Role Name",
"IsCustom": true,
"Description": "Role description",
"Type": "CustomRole",
"Permissions": [
{
"Actions": ["Microsoft.Storage/*/read"],
"NotActions": ["Microsoft.Storage/*/delete"],
"DataActions": ["Microsoft.Storage/storageAccounts/blobServices/containers/blobs/*"],
"NotDataActions": []
}
],
"CreatedOn": "2024-01-01",
"UpdatedOn": "2024-01-01"
}
Permission Type Classification
- Control Plane: Management operations (e.g.,
Microsoft.Compute/virtualMachines/start/action) - Data Plane: Data operations (e.g.,
Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read)
Examples
See the examples/ directory for pre-built roles like:
devops-developer.json- DevOps developer permissionsjunior-developer.json- Junior developer restricted permissionssenior-developer.json- Senior developer full permissions
Contributing
For issues or feature requests, open a GitHub issue.
License
MIT - Paulo Correia
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file azure_custom_role_tool-1.0.0.tar.gz.
File metadata
- Download URL: azure_custom_role_tool-1.0.0.tar.gz
- Upload date:
- Size: 42.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f45a60824190e3bcd2d94853644fdc8b336fec49a479145c5aaf4caffb8fb812
|
|
| MD5 |
9251cb56c7c6a2dadca3e79406bbfd1f
|
|
| BLAKE2b-256 |
e0760967a73de275bfc8a319d52ec70b74b045c13c09bf9620626a670ed41386
|
Provenance
The following attestation bundles were made for azure_custom_role_tool-1.0.0.tar.gz:
Publisher:
publish-pypi.yml on pacorreia/azure-custom-role-tool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
azure_custom_role_tool-1.0.0.tar.gz -
Subject digest:
f45a60824190e3bcd2d94853644fdc8b336fec49a479145c5aaf4caffb8fb812 - Sigstore transparency entry: 990575549
- Sigstore integration time:
-
Permalink:
pacorreia/azure-custom-role-tool@e9c371ad4ee5615148bd4579a1f0d55a9d6940c2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pacorreia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@e9c371ad4ee5615148bd4579a1f0d55a9d6940c2 -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file azure_custom_role_tool-1.0.0-py3-none-any.whl.
File metadata
- Download URL: azure_custom_role_tool-1.0.0-py3-none-any.whl
- Upload date:
- Size: 23.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48af915073b815583bb2f2f947a8c710910e6d02d519bf389c760775ab2070d5
|
|
| MD5 |
623d0637b13e32049c54f51f40cb661a
|
|
| BLAKE2b-256 |
9e03f8685d758d242c11f93281184ee114b5ad720ed34b5a9b5336a202958a9d
|
Provenance
The following attestation bundles were made for azure_custom_role_tool-1.0.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on pacorreia/azure-custom-role-tool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
azure_custom_role_tool-1.0.0-py3-none-any.whl -
Subject digest:
48af915073b815583bb2f2f947a8c710910e6d02d519bf389c760775ab2070d5 - Sigstore transparency entry: 990575551
- Sigstore integration time:
-
Permalink:
pacorreia/azure-custom-role-tool@e9c371ad4ee5615148bd4579a1f0d55a9d6940c2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pacorreia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@e9c371ad4ee5615148bd4579a1f0d55a9d6940c2 -
Trigger Event:
workflow_run
-
Statement type: