|
| 1 | +# Azure CLI Cloudhsm Extension # |
| 2 | +This is an extension to Azure CLI to manage Cloudhsm resources. |
| 3 | + |
| 4 | +## Installation |
| 5 | + |
| 6 | +Install this extension using the CLI command: |
| 7 | +```bash |
| 8 | +az extension add --name cloudhsm |
| 9 | +``` |
| 10 | + |
| 11 | +## Sample Usage |
| 12 | + |
| 13 | +### Prerequisites |
| 14 | +- Azure subscription |
| 15 | +- Resource group |
| 16 | +- Storage account with blob container (for backup/restore operations) |
| 17 | +- User-assigned managed identity (for backup/restore operations) |
| 18 | + |
| 19 | +### 1. Create a CloudHSM Cluster |
| 20 | + |
| 21 | +#### Basic CloudHSM creation: |
| 22 | +```bash |
| 23 | +az cloudhsm create \ |
| 24 | + --resource-group myResourceGroup \ |
| 25 | + --name myCloudHSM \ |
| 26 | + --location eastus2 \ |
| 27 | + --sku Standard_B1 \ |
| 28 | + --tags Department=Security Environment=Production |
| 29 | +``` |
| 30 | + |
| 31 | +#### CloudHSM with user-assigned managed identity: |
| 32 | +```bash |
| 33 | +az cloudhsm create \ |
| 34 | + --resource-group myResourceGroup \ |
| 35 | + --name myCloudHSM \ |
| 36 | + --location eastus2 \ |
| 37 | + --sku Standard_B1 \ |
| 38 | + --domain-name-label-scope TenantReuse \ |
| 39 | + --mi-user-assigned /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity \ |
| 40 | + --tags Department=Security Environment=Production |
| 41 | +``` |
| 42 | + |
| 43 | +#### Available SKUs: |
| 44 | +- `Standard_B1` (default) |
| 45 | + |
| 46 | + |
| 47 | +### 2. List CloudHSM Clusters |
| 48 | + |
| 49 | +#### List all CloudHSM clusters in subscription: |
| 50 | +```bash |
| 51 | +az cloudhsm list |
| 52 | +``` |
| 53 | + |
| 54 | +#### List CloudHSM clusters in a specific resource group: |
| 55 | +```bash |
| 56 | +az cloudhsm list --resource-group myResourceGroup |
| 57 | +``` |
| 58 | + |
| 59 | +### 3. Show CloudHSM Details |
| 60 | + |
| 61 | +```bash |
| 62 | +az cloudhsm show \ |
| 63 | + --resource-group myResourceGroup \ |
| 64 | + --name myCloudHSM |
| 65 | +``` |
| 66 | + |
| 67 | +### 4. Update CloudHSM |
| 68 | + |
| 69 | +```bash |
| 70 | +az cloudhsm update \ |
| 71 | + --resource-group myResourceGroup \ |
| 72 | + --name myCloudHSM \ |
| 73 | + --tags Department=Security Environment=Production Updated=true |
| 74 | +``` |
| 75 | + |
| 76 | +### 5. Backup Operations |
| 77 | + |
| 78 | +#### Start a backup: |
| 79 | +```bash |
| 80 | +az cloudhsm backup start \ |
| 81 | + --resource-group myResourceGroup \ |
| 82 | + --cluster-name myCloudHSM \ |
| 83 | + --blob-container-uri "https://mystorageaccount.blob.core.windows.net/backups" |
| 84 | +``` |
| 85 | + |
| 86 | +#### Show backup status: |
| 87 | +```bash |
| 88 | +az cloudhsm backup show \ |
| 89 | + --resource-group myResourceGroup \ |
| 90 | + --cluster-name myCloudHSM \ |
| 91 | + --job-id backup-job-id |
| 92 | +``` |
| 93 | + |
| 94 | +### 6. Restore Operations |
| 95 | + |
| 96 | +#### Start a restore from backup: |
| 97 | +```bash |
| 98 | +az cloudhsm restore start \ |
| 99 | + --resource-group myResourceGroup \ |
| 100 | + --cluster-name myCloudHSM \ |
| 101 | + --backup-id cloudhsm-0e35c989-c582-4b3c-958d-596e4c4fe133 \ |
| 102 | + --blob-container-uri "https://mystorageaccount.blob.core.windows.net/backups" |
| 103 | +``` |
| 104 | + |
| 105 | +#### Show restore status: |
| 106 | +```bash |
| 107 | +az cloudhsm restore show \ |
| 108 | + --resource-group myResourceGroup \ |
| 109 | + --cluster-name myCloudHSM \ |
| 110 | + --job-id restore-job-id |
| 111 | +``` |
| 112 | + |
| 113 | +### 7. Delete CloudHSM |
| 114 | + |
| 115 | +```bash |
| 116 | +az cloudhsm delete \ |
| 117 | + --resource-group myResourceGroup \ |
| 118 | + --name myCloudHSM \ |
| 119 | +``` |
| 120 | + |
| 121 | +## Common Scenarios |
| 122 | + |
| 123 | +### Scenario 1: Setup CloudHSM with Backup Strategy |
| 124 | +```bash |
| 125 | +# 1. Create CloudHSM |
| 126 | +az cloudhsm create \ |
| 127 | + --resource-group myResourceGroup \ |
| 128 | + --name myCloudHSM \ |
| 129 | + --location eastus2 \ |
| 130 | + --sku Standard_B1 |
| 131 | + |
| 132 | +# 2. Start initial backup |
| 133 | +az cloudhsm backup start \ |
| 134 | + --resource-group myResourceGroup \ |
| 135 | + --cluster-name myCloudHSM \ |
| 136 | + --blob-container-uri "https://mystorageaccount.blob.core.windows.net/backups" |
| 137 | +``` |
| 138 | + |
| 139 | +### Scenario 2: Disaster Recovery |
| 140 | +```bash |
| 141 | +# 1. Create new CloudHSM cluster |
| 142 | +az cloudhsm create \ |
| 143 | + --resource-group myDRResourceGroup \ |
| 144 | + --name myDRCloudHSM \ |
| 145 | + --location westus2 \ |
| 146 | + --sku Standard_B1 |
| 147 | + |
| 148 | +# 2. Restore from backup |
| 149 | +az cloudhsm restore start \ |
| 150 | + --resource-group myDRResourceGroup \ |
| 151 | + --cluster-name myDRCloudHSM \ |
| 152 | + --backup-id your-backup-id \ |
| 153 | + --blob-container-uri "https://mystorageaccount.blob.core.windows.net/backups" |
| 154 | +``` |
| 155 | + |
| 156 | +## Best Practices |
| 157 | + |
| 158 | +1. **Regular backups** to protect against data loss |
| 159 | +2. **Monitor operations** to track the status of long-running operations |
| 160 | +3. **Tag resources** for better organization and cost management |
| 161 | +4. **Store backups** in geo-redundant storage for disaster recovery |
| 162 | + |
| 163 | +## Additional Resources |
| 164 | + |
| 165 | +- [Azure CloudHSM Documentation](https://docs.microsoft.com/azure/cloud-hsm) |
| 166 | +- [Azure CLI Documentation](https://docs.microsoft.com/cli/azure/) |
| 167 | +- [Azure Storage Documentation](https://docs.microsoft.com/azure/storage/) |
0 commit comments