Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
75b99e5
Create Az cloudhsm extension for 2025-03-31 #27947
emmeliaAra Jun 13, 2025
07cdef1
Updates for azdev style
emmeliaAra Jun 13, 2025
c1ee0cf
Add details in history.rst
emmeliaAra Jun 16, 2025
6c4862d
Merge branch 'main' into cloudHsm-2025-03-31-v
emmeliaAra Jun 16, 2025
eb4f848
Add short abbreviation for domain-name-label-scope
emmeliaAra Jun 16, 2025
2a84d1e
Unregister backup/restore show commands
emmeliaAra Jun 16, 2025
3ad5be1
update example for Delete
emmeliaAra Jun 16, 2025
13397ae
Create Az cloudhsm extension for 2025-03-31 #27947
emmeliaAra Jun 13, 2025
e91f7aa
Updates for azdev style
emmeliaAra Jun 13, 2025
27022d9
Add details in history.rst
emmeliaAra Jun 16, 2025
6c35efd
Add short abbreviation for domain-name-label-scope
emmeliaAra Jun 16, 2025
3a93e3b
Unregister backup/restore show commands
emmeliaAra Jun 16, 2025
d31f666
update example for Delete
emmeliaAra Jun 16, 2025
e79d318
Fixing Build Gates
jkapil Jun 20, 2025
6b8df9c
Adding Readme for Cloudhsm CLI commands
jkapil Jun 20, 2025
655b2e0
Fixing test script
jkapil Jun 20, 2025
9883d9a
Removing wait command to align with managedhsm
jkapil Jun 20, 2025
635b5a7
Making vesion consistent across files
jkapil Jun 23, 2025
dd6cc08
updating test data.
jkapil Jun 23, 2025
b3e527c
Fixing local test error
jkapil Jun 23, 2025
a796d64
Fixing test data
jkapil Jun 23, 2025
38fdc23
Unfortunately the swagger property name is called azureStorageBlobCon…
jkapil Jun 23, 2025
16566b5
Updated readme file and Servicename json
emmeliaAra Jun 23, 2025
7bdf11c
Merged with Kapil's branch
emmeliaAra Jun 23, 2025
d43c688
Comment backup and restore test cases - to be run locally only
emmeliaAra Jun 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/cloudhsm/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

Release History
===============

1.0.0b1
++++++
* Initial release.
167 changes: 167 additions & 0 deletions src/cloudhsm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# Azure CLI Cloudhsm Extension #
This is an extension to Azure CLI to manage Cloudhsm resources.

## Installation

Install this extension using the CLI command:
```bash
az extension add --name cloudhsm
```

## Sample Usage

### Prerequisites
- Azure subscription
- Resource group
- Storage account with blob container (for backup/restore operations)
- User-assigned managed identity (for backup/restore operations)

### 1. Create a CloudHSM Cluster

#### Basic CloudHSM creation:
```bash
az cloudhsm create \
--resource-group myResourceGroup \
--name myCloudHSM \
--location eastus2 \
--sku Standard_B1 \
--tags Department=Security Environment=Production
```

#### CloudHSM with user-assigned managed identity:
```bash
az cloudhsm create \
--resource-group myResourceGroup \
--name myCloudHSM \
--location eastus2 \
--sku Standard_B1 \
--domain-name-label-scope TenantReuse \
--mi-user-assigned /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity \
--tags Department=Security Environment=Production
```

#### Available SKUs:
- `Standard_B1` (default)


### 2. List CloudHSM Clusters

#### List all CloudHSM clusters in subscription:
```bash
az cloudhsm list
```

#### List CloudHSM clusters in a specific resource group:
```bash
az cloudhsm list --resource-group myResourceGroup
```

### 3. Show CloudHSM Details

```bash
az cloudhsm show \
--resource-group myResourceGroup \
--name myCloudHSM
```

### 4. Update CloudHSM

```bash
az cloudhsm update \
--resource-group myResourceGroup \
--name myCloudHSM \
--tags Department=Security Environment=Production Updated=true
```

### 5. Backup Operations

#### Start a backup:
```bash
az cloudhsm backup start \
--resource-group myResourceGroup \
--cluster-name myCloudHSM \
--blob-container-uri "https://mystorageaccount.blob.core.windows.net/backups"
```

#### Show backup status:
```bash
az cloudhsm backup show \
--resource-group myResourceGroup \
--cluster-name myCloudHSM \
--job-id backup-job-id
```

### 6. Restore Operations

#### Start a restore from backup:
```bash
az cloudhsm restore start \
--resource-group myResourceGroup \
--cluster-name myCloudHSM \
--backup-id cloudhsm-0e35c989-c582-4b3c-958d-596e4c4fe133 \
--blob-container-uri "https://mystorageaccount.blob.core.windows.net/backups"
```

#### Show restore status:
```bash
az cloudhsm restore show \
--resource-group myResourceGroup \
--cluster-name myCloudHSM \
--job-id restore-job-id
```

### 7. Delete CloudHSM

```bash
az cloudhsm delete \
--resource-group myResourceGroup \
--name myCloudHSM \
```

## Common Scenarios

### Scenario 1: Setup CloudHSM with Backup Strategy
```bash
# 1. Create CloudHSM
az cloudhsm create \
--resource-group myResourceGroup \
--name myCloudHSM \
--location eastus2 \
--sku Standard_B1

# 2. Start initial backup
az cloudhsm backup start \
--resource-group myResourceGroup \
--cluster-name myCloudHSM \
--blob-container-uri "https://mystorageaccount.blob.core.windows.net/backups"
```

### Scenario 2: Disaster Recovery
```bash
# 1. Create new CloudHSM cluster
az cloudhsm create \
--resource-group myDRResourceGroup \
--name myDRCloudHSM \
--location westus2 \
--sku Standard_B1

# 2. Restore from backup
az cloudhsm restore start \
--resource-group myDRResourceGroup \
--cluster-name myDRCloudHSM \
--backup-id your-backup-id \
--blob-container-uri "https://mystorageaccount.blob.core.windows.net/backups"
```

## Best Practices

1. **Regular backups** to protect against data loss
2. **Monitor operations** to track the status of long-running operations
3. **Tag resources** for better organization and cost management
4. **Store backups** in geo-redundant storage for disaster recovery

## Additional Resources

- [Azure CloudHSM Documentation](https://docs.microsoft.com/azure/cloud-hsm)
- [Azure CLI Documentation](https://docs.microsoft.com/cli/azure/)
- [Azure Storage Documentation](https://docs.microsoft.com/azure/storage/)
42 changes: 42 additions & 0 deletions src/cloudhsm/azext_cloudhsm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader
from azext_cloudhsm._help import helps # pylint: disable=unused-import


class CloudhsmCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
custom_command_type = CliCommandType(
operations_tmpl='azext_cloudhsm.custom#{}')
super().__init__(cli_ctx=cli_ctx,
custom_command_type=custom_command_type)

def load_command_table(self, args):
from azext_cloudhsm.commands import load_command_table
from azure.cli.core.aaz import load_aaz_command_table
try:
from . import aaz
except ImportError:
aaz = None
if aaz:
load_aaz_command_table(
loader=self,
aaz_pkg_name=aaz.__name__,
args=args
)
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azext_cloudhsm._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = CloudhsmCommandsLoader
11 changes: 11 additions & 0 deletions src/cloudhsm/azext_cloudhsm/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: disable=line-too-long
# pylint: disable=too-many-lines

from knack.help_files import helps # pylint: disable=unused-import
13 changes: 13 additions & 0 deletions src/cloudhsm/azext_cloudhsm/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: disable=too-many-lines
# pylint: disable=too-many-statements


def load_arguments(self, _): # pylint: disable=unused-argument
pass
6 changes: 6 additions & 0 deletions src/cloudhsm/azext_cloudhsm/aaz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------
10 changes: 10 additions & 0 deletions src/cloudhsm/azext_cloudhsm/aaz/latest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

23 changes: 23 additions & 0 deletions src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/__cmd_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"cloudhsm",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Cloud Hsm Cluster
"""
pass


__all__ = ["__CMDGroup"]
16 changes: 16 additions & 0 deletions src/cloudhsm/azext_cloudhsm/aaz/latest/cloudhsm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._create import *
from ._delete import *
from ._list import *
from ._show import *
from ._update import *
Loading
Loading