Muokkaa

Jaa


Manage Azure Managed Instance for Apache Cassandra resources by using the Azure CLI

This article describes common commands to automate the management of your Azure Managed Instance for Apache Cassandra clusters and datacenters by using the Azure CLI.

Prerequisites

This article requires Azure CLI version 2.30.0 or later. If you're using Azure Cloud Shell, the latest version is already installed.

Important

You can't rename Manage Azure Managed Instance for Apache Cassandra resources. Renaming these resources violates how Azure Resource Manager works with resource URIs.

Manage clusters

The following sections demonstrate how to manage Azure Managed Instance for Apache Cassandra clusters:

Create a cluster

Create an Azure Managed Instance for Apache Cassandra cluster by using the az managed-cassandra cluster create command:

resourceGroupName='MyResourceGroup'
clusterName='cassandra-hybrid-cluster'
location='West US'
delegatedManagementSubnetId='/subscriptions/<subscription id>/resourceGroups/customer-vnet-rg/providers/Microsoft.Network/virtualNetworks/customer-vnet/subnets/management'
initialCassandraAdminPassword='myPassword'

# You can override the cluster name if the original name is not legal for an Azure resource:
# overrideClusterName='ClusterNameIllegalForAzureResource'
# The default Cassandra version is v3.11

az managed-cassandra cluster create \
    --cluster-name $clusterName \
    --resource-group $resourceGroupName \
    --location $location \
    --delegated-management-subnet-id $delegatedManagementSubnetId \
    --initial-cassandra-admin-password $initialCassandraAdminPassword \

Delete a cluster

Delete a cluster by using the az managed-cassandra cluster delete command:

resourceGroupName='MyResourceGroup'
clusterName='cassandra-hybrid-cluster'

az managed-cassandra cluster delete \
    --cluster-name $clusterName \
    --resource-group $resourceGroupName

Get cluster details

Get cluster details by using the az managed-cassandra cluster show command:

resourceGroupName='MyResourceGroup'
clusterName='cassandra-hybrid-cluster'

az managed-cassandra cluster show \
    --cluster-name $clusterName \
    --resource-group $resourceGroupName

Get the cluster node status

Get the status of cluster nodes by using the az managed-cassandra cluster status command:

clusterName='cassandra-hybrid-cluster'
resourceGroupName='MyResourceGroup'

az managed-cassandra cluster status \
    --cluster-name $clusterName \
    --resource-group $resourceGroupName

List clusters by resource group

List clusters by resource group by using the az managed-cassandra cluster list command:

subscriptionId='MySubscriptionId'
resourceGroupName='MyResourceGroup'

az managed-cassandra cluster list\
    --resource-group $resourceGroupName

List clusters by subscription ID

List clusters by subscription ID by using the az managed-cassandra cluster list command:

# Set your subscription ID
az account set -s <subscriptionID>

az managed-cassandra cluster list

Manage datacenters

The following sections demonstrate how to manage Azure Managed Instance for Apache Cassandra datacenters:

Create a datacenter

Create a datacenter by using the az managed-cassandra datacenter create command:

resourceGroupName='MyResourceGroup'
clusterName='cassandra-hybrid-cluster'
dataCenterName='dc1'
dataCenterLocation='eastus2'
delegatedSubnetId='/subscriptions/<SubscriptionID>/resourceGroups/customer-vnet-rg/providers/Microsoft.Network/virtualNetworks/customer-vnet/subnets/dc1-subnet'
virtualMachineSKU='Standard_D8s_v4'
noOfDisksPerNode=4

az managed-cassandra datacenter create \
    --resource-group $resourceGroupName \
    --cluster-name $clusterName \
    --data-center-name $dataCenterName \
    --data-center-location $dataCenterLocation \
    --delegated-subnet-id $delegatedSubnetId \
    --node-count 3 
    --sku $virtualMachineSKU \
    --disk-capacity $noOfDisksPerNode \
    --availability-zone false

Choose the value for --sku from the following available virtual machine (VM) options:

  • Standard_E8s_v4
  • Standard_E16s_v4
  • Standard_E20s_v4
  • Standard_E32s_v4
  • Standard_DS13_v2
  • Standard_DS14_v2
  • Standard_D8s_v4
  • Standard_D16s_v4
  • Standard_D32s_v4
  • Standard_L8s_v3
  • Standard_L16s_v3
  • Standard_L32s_v3
  • Standard_L8as_v3
  • Standard_L16as_v3
  • Standard_L32as_v3

Currently, Azure Managed Instance for Apache Cassandra doesn't support transitioning across VM families. For instance, if you currently have a Standard_DS13_v2 VM and are interested in upgrading to a larger VM such as Standard_DS14_v2, this option isn't available. However, you can open a support ticket to request the upgrade.

In the preceding command, --availability-zone is set to false. To enable availability zones, set this value to true. Availability zones increase the service-level agreement (SLA) for availability of the service. For more information, review the full SLA details.

Warning

Azure Managed Instance for Apache Cassandra doesn't support availability zones in all regions. If you select a region where availability zones aren't supported, deployments will fail. See the list of supported regions.

The successful deployment of availability zones is also subject to the availability of compute resources in all of the zones in a region. Deployments might fail if the VM or the capacity that you selected isn't available across all zones.

Delete a datacenter

Delete a datacenter by using the az managed-cassandra datacenter delete command:

resourceGroupName='MyResourceGroup'
clusterName='cassandra-hybrid-cluster'
dataCenterName='dc1'

az managed-cassandra datacenter delete \
    --resource-group $resourceGroupName \
    --cluster-name $clusterName \
    --data-center-name $dataCenterName 

Warning

If you have more than one datacenter in your cluster, you must remove any references to the datacenter that you're trying to delete in any keyspace replication strategy settings first. This command will fail if any keyspaces within your cluster still have references to the datacenter.

Get datacenter details

Get datacenter details by using the az managed-cassandra datacenter show command:

resourceGroupName='MyResourceGroup'
clusterName='cassandra-hybrid-cluster'
dataCenterName='dc1'

az managed-cassandra datacenter show \
    --resource-group $resourceGroupName \
    --cluster-name $clusterName \
    --data-center-name $dataCenterName 

Update or scale a datacenter

Update or scale a datacenter by using the az managed-cassandra datacenter update command:

resourceGroupName='MyResourceGroup'
clusterName='cassandra-hybrid-cluster'
dataCenterName='dc1'

az managed-cassandra datacenter update \
    --resource-group $resourceGroupName \
    --cluster-name $clusterName \
    --data-center-name $dataCenterName \
    --node-count 13 

To scale a datacenter, change the --node-count value.

Get the Cassandra configuration

Get the current YAML configuration of a node by using the az managed-cassandra cluster invoke-command command:

resourceGroupName='MyResourceGroup'
clusterName='cassandra-hybrid-cluster'
commandName='get-cassandra-yaml'
 
az managed-cassandra cluster invoke-command \
    --resource-group $resourceGroupName \
    --cluster-name $clusterName \
    --host <ip address> \
    --command-name 'get-cassandra-yaml'

You can make the output more readable by using the following commands:

$output = az managed-cassandra cluster invoke-command \
    --resource-group $resourceGroupName \
    --cluster-name $clusterName \
    --host <ip address> \
    --command-name 'get-cassandra-yaml' \
    | ConvertFrom-Json
$output.commandOutput

Update the Cassandra configuration

Change the Cassandra configuration on a datacenter by using the az managed-cassandra datacenter update command. You need to Base64 encode the YAML fragment by using an online tool.

For example, consider the following YAML fragment:

column_index_size_in_kb: 16
read_request_timeout_in_ms: 10000

When it's encoded, the YAML is converted to: Y29sdW1uX2luZGV4X3NpemVfaW5fa2I6IDE2CnJlYWRfcmVxdWVzdF90aW1lb3V0X2luX21zOiAxMDAwMA==.

Here's the az managed-cassandra datacenter update command with the encoded YAML fragment:

resourceGroupName='MyResourceGroup'
clusterName='cassandra-hybrid-cluster'
dataCenterName='dc1'
dataCenterLocation='eastus'
yamlFragment='Y29sdW1uX2luZGV4X3NpemVfaW5fa2I6IDE2CnJlYWRfcmVxdWVzdF90aW1lb3V0X2luX21zOiAxMDAwMA=='

az managed-cassandra datacenter update \
    --resource-group $resourceGroupName \
    --cluster-name $clusterName \
    --data-center-name $dataCenterName \
    --base64-encoded-cassandra-yaml-fragment $yamlFragment

Important

Ensure that the Cassandra YAML settings that you provide are appropriate for your version of Cassandra. See the Cassandra v3.11 settings and the Cassandra v4.0 settings. You're not allowed to update the following YAML settings:

  • cluster_name
  • seed_provider
  • initial_token
  • autobootstrap
  • client_encryption_options
  • server_encryption_options
  • transparent_data_encryption_options
  • audit_logging_options
  • authenticator
  • authorizer
  • role_manager
  • storage_port
  • ssl_storage_port
  • native_transport_port
  • native_transport_port_ssl
  • listen_address
  • listen_interface
  • broadcast_address
  • hints_directory
  • data_file_directories
  • commitlog_directory
  • cdc_raw_directory
  • saved_caches_directory
  • endpoint_snitch
  • partitioner
  • rpc_address
  • rpc_interface

Get the datacenters in a cluster

Get datacenters in a cluster by using the az managed-cassandra datacenter list command:

resourceGroupName='MyResourceGroup'
clusterName='cassandra-hybrid-cluster'

az managed-cassandra datacenter list \
    --resource-group $resourceGroupName \
    --cluster-name $clusterName

Next steps