Skip to content

Commit eea2730

Browse files
jkapilemmeliaAra
andauthored
Create Az CloudHsm Extension for 2025-03-31 (#8885)
* Create Az cloudhsm extension for 2025-03-31 #27947 * Updates for azdev style * Add details in history.rst * Add short abbreviation for domain-name-label-scope * Unregister backup/restore show commands * update example for Delete * Fixing Build Gates * Adding Readme for Cloudhsm CLI commands * Fixing test script * Removing wait command to align with managedhsm * Making vesion consistent across files * updating test data. * Fixing local test error * Fixing test data * Unfortunately the swagger property name is called azureStorageBlobContainerUri and not blobContainerUri --------- Co-authored-by: emmeliaAra <[email protected]>
1 parent d33d6c7 commit eea2730

33 files changed

+4481
-0
lines changed

src/cloudhsm/HISTORY.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. :changelog:
2+
3+
Release History
4+
===============
5+
6+
1.0.0b1
7+
++++++
8+
* Initial release.

src/cloudhsm/README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
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/)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
from azure.cli.core import AzCommandsLoader
9+
from azext_cloudhsm._help import helps # pylint: disable=unused-import
10+
11+
12+
class CloudhsmCommandsLoader(AzCommandsLoader):
13+
14+
def __init__(self, cli_ctx=None):
15+
from azure.cli.core.commands import CliCommandType
16+
custom_command_type = CliCommandType(
17+
operations_tmpl='azext_cloudhsm.custom#{}')
18+
super().__init__(cli_ctx=cli_ctx,
19+
custom_command_type=custom_command_type)
20+
21+
def load_command_table(self, args):
22+
from azext_cloudhsm.commands import load_command_table
23+
from azure.cli.core.aaz import load_aaz_command_table
24+
try:
25+
from . import aaz
26+
except ImportError:
27+
aaz = None
28+
if aaz:
29+
load_aaz_command_table(
30+
loader=self,
31+
aaz_pkg_name=aaz.__name__,
32+
args=args
33+
)
34+
load_command_table(self, args)
35+
return self.command_table
36+
37+
def load_arguments(self, command):
38+
from azext_cloudhsm._params import load_arguments
39+
load_arguments(self, command)
40+
41+
42+
COMMAND_LOADER_CLS = CloudhsmCommandsLoader
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: disable=line-too-long
9+
# pylint: disable=too-many-lines
10+
11+
from knack.help_files import helps # pylint: disable=unused-import
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: disable=too-many-lines
9+
# pylint: disable=too-many-statements
10+
11+
12+
def load_arguments(self, _): # pylint: disable=unused-argument
13+
pass
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command_group(
15+
"cloudhsm",
16+
)
17+
class __CMDGroup(AAZCommandGroup):
18+
"""Manage Cloud Hsm Cluster
19+
"""
20+
pass
21+
22+
23+
__all__ = ["__CMDGroup"]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from .__cmd_group import *
12+
from ._create import *
13+
from ._delete import *
14+
from ._list import *
15+
from ._show import *
16+
from ._update import *

0 commit comments

Comments
 (0)