Como criar e gerir Cache do Azure para Redis com a CLI clássica do Azure

A CLI clássica do Azure é uma excelente forma de gerir a sua infraestrutura do Azure a partir de qualquer plataforma. Este artigo mostra como criar e gerir as suas instâncias de Cache do Azure para Redis com a CLI clássica do Azure.

Importante

Este artigo contém conteúdo que requer a CLI clássica do Azure. Esta é uma versão mais antiga da CLI do Azure que deve ser utilizada apenas com o modelo de implementação clássica do Azure.

Para instalar a CLI clássica, veja Instalar a CLI clássica do Azure e instalar a CLI do Azure atual para implementações de Resource Manager do Azure, veja Instalar a CLI do Azure.

Nota

Para obter os scripts de exemplo mais recentes da CLI do Azure, veja Exemplos de Cache do Azure para Redis da CLI do Azure.

Pré-requisitos

Para criar e gerir Cache do Azure para Redis instâncias com a CLI clássica do Azure, tem de concluir os seguintes passos.

Cache do Azure para Redis propriedades

As seguintes propriedades são utilizadas ao criar e atualizar Cache do Azure para Redis instâncias.

Propriedade Comutador Descrição
name -n, --name Nome do Cache do Azure para Redis.
grupo de recursos -g, --resource-group Nome do Grupo de Recursos.
localização -l, --location Localização para criar a cache.
size -z, --size Tamanho da Cache do Azure para Redis. Valores válidos: [C0, C1, C2, C3, C4, C5, C6, P1, P2, P3, P4]
sku -x, --sku SKU redis. Deve ser um de: [Básico, Standard, Premium]
EnableNonSslPort -e, --enable-non-ssl-port Propriedade EnableNonSslPort do Cache do Azure para Redis. Adicione este sinalizador se pretender ativar a Porta não TLS/SSL para a cache
Configuração do Redis -c, --redis-configuration Configuração do Redis. Introduza uma cadeia formatada JSON de chaves de configuração e valores aqui. Formatar:"{"":"","":""}"
Configuração do Redis -f, --redis-configuration-file Configuração do Redis. Introduza o caminho de um ficheiro que contenha chaves de configuração e valores aqui. Formatar para a entrada de ficheiro: {":"","":"""}
Contagem de Partições Horizontais -r, --shard-count Número de Partições Horizontais a criar numa Cache de Cluster Premium com clustering.
Rede Virtual -v, --virtual-network Ao alojar a cache numa VNET, especifica o ID de recurso exato Resource Manager da rede virtual para implementar o Cache do Azure para Redis. Formato de exemplo: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.ClassicNetwork/VirtualNetworks/vnet1
tipo de chave -t, --key-type Tipo de chave a renovar. Valores válidos: [Primário, Secundário]
StaticIP -p, --static-ip <static-ip> Ao alojar a cache numa VNET, especifica um endereço IP exclusivo na sub-rede da cache. Se não for fornecido, é escolhido um para si a partir da sub-rede.
Sub-rede t, --sub-rede <sub-rede> Ao alojar a cache numa VNET, especifica o nome da sub-rede na qual pretende implementar a cache.
VirtualNetwork -v, --virtual-network <virtual-network> Ao alojar a cache numa VNET, especifica o ID de recurso exato Resource Manager da rede virtual para implementar o Cache do Azure para Redis. Formato de exemplo: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.ClassicNetwork/VirtualNetworks/vnet1
Subscrição -s, --subscription O identificador da subscrição.

Ver todos os comandos Cache do Azure para Redis

Para ver todos os comandos Cache do Azure para Redis e os respetivos parâmetros, utilize o azure rediscache -h comando .

C:\>azure rediscache -h
help:    Commands to manage your Azure Cache for Redis(s)
help:
help:    Create an Azure Cache for Redis
help:      rediscache create [--name <name> --resource-group <resource-group> --location <location> [options]]
help:
help:    Delete an existing Azure Cache for Redis
help:      rediscache delete [--name <name> --resource-group <resource-group> ]
help:
help:    List all Azure Cache for Redis within your Subscription or Resource Group
help:      rediscache list [options]
help:
help:    Show properties of an existing Azure Cache for Redis
help:      rediscache show [--name <name> --resource-group <resource-group>]
help:
help:    Change settings of an existing Azure Cache for Redis
help:      rediscache set [--name <name> --resource-group <resource-group> --redis-configuration <redis-configuration>/--redis-configuration-file <redisConfigurationFile>]
help:
help:    Renew the authentication key for an existing Azure Cache for Redis
help:      rediscache renew-key [--name <name> --resource-group <resource-group> ]
help:
help:    Lists Primary and Secondary key of an existing Azure Cache for Redis
help:      rediscache list-keys [--name <name> --resource-group <resource-group>]
help:
help:    Options:
help:      -h, --help  output usage information
help:
help:    Current Mode: arm (Azure Resource Management)

Criar uma Cache do Azure para Redis

Para criar uma Cache do Azure para Redis, utilize o seguinte comando:

    azure rediscache create [--name <name> --resource-group <resource-group> --location <location> [options]]

Para obter mais informações sobre este comando, execute o azure rediscache create -h comando .

C:\>azure rediscache create -h
help:    Create an Azure Cache for Redis
help:
help:    Usage: rediscache create [--name <name> --resource-group <resource-group> --location <location> [options]]
help:
help:    Options:
help:      -h, --help                                               output usage information
help:      -v, --verbose                                            use verbose output
help:      -vv                                                      more verbose with debug output
help:      --json                                                   use json output
help:      -n, --name <name>                                        Name of the Azure Cache for Redis.
help:      -g, --resource-group <resource-group>                    Name of the Resource Group
help:      -l, --location <location>                                Location to create cache.
help:      -z, --size <size>                                        Size of the Azure Cache for Redis. Valid values: [C0, C1, C2, C3, C4, C5, C6, P1, P2, P3, P4]
help:      -x, --sku <sku>                                          Redis SKU. Should be one of : [Basic, Standard, Premium]
help:      -e, --enable-non-ssl-port                                EnableNonSslPort property of the Azure Cache for Redis. Add this flag if you want to enable the non-TLS/SSL Port for your cache
help:      -c, --redis-configuration <redis-configuration>          Redis Configuration. Enter a JSON formatted string of configuration keys and values here. Format:"{"<key1>":"<value1>","<key2>":"<value2>"}"
help:      -f, --redis-configuration-file <redisConfigurationFile>  Redis Configuration. Enter the path of a file containing configuration keys and values here. Format for the file entry: {"<key1>":"<value1>","<key2>":"<value2>"}
help:      -r, --shard-count <shard-count>                          Number of Shards to create on a Premium Cluster Cache
help:      -v, --virtual-network <virtual-network>                  The exact ARM resource ID of the virtual network to deploy the Azure Cache for Redis in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.ClassicNetwork/VirtualNetworks/vnet1
help:      -t, --subnet <subnet>                                    Required when deploying an Azure Cache for Redis inside an existing Azure Virtual Network
help:      -p, --static-ip <static-ip>                              Required when deploying an Azure Cache for Redis inside an existing Azure Virtual Network
help:      -s, --subscription <id>                                  the subscription identifier
help:
help:    Current Mode: arm (Azure Resource Management)

Eliminar uma Cache do Azure para Redis existente

Para eliminar uma Cache do Azure para Redis, utilize o seguinte comando:

    azure rediscache delete [--name <name> --resource-group <resource-group> ]

Para obter mais informações sobre este comando, execute o azure rediscache delete -h comando .

C:\>azure rediscache delete -h
help:    Delete an existing Azure Cache for Redis
help:
help:    Usage: rediscache delete [--name <name> --resource-group <resource-group> ]
help:
help:    Options:
help:      -h, --help                             output usage information
help:      -v, --verbose                          use verbose output
help:      -vv                                    more verbose with debug output
help:      --json                                 use json output
help:      -n, --name <name>                      Name of the Azure Cache for Redis.
help:      -g, --resource-group <resource-group>  Name of the Resource Group under which the cache exists
help:      -s, --subscription <subscription>      the subscription identifier
help:
help:    Current Mode: arm (Azure Resource Management)

Listar todos os Cache do Azure para Redis na subscrição ou grupo de recursos

Para listar todas as Cache do Azure para Redis na subscrição ou grupo de recursos, utilize o seguinte comando:

    azure rediscache list [options]

Para obter mais informações sobre este comando, execute o azure rediscache list -h comando .

C:\>azure rediscache list -h
help:    List all Azure Cache for Redis within your Subscription or Resource Group
help:
help:    Usage: rediscache list [options]
help:
help:    Options:
help:      -h, --help                             output usage information
help:      -v, --verbose                          use verbose output
help:      -vv                                    more verbose with debug output
help:      --json                                 use json output
help:      -g, --resource-group <resource-group>  Name of the Resource Group
help:      -s, --subscription <subscription>      the subscription identifier
help:
help:    Current Mode: arm (Azure Resource Management)

Mostrar propriedades de uma Cache do Azure para Redis existente

Para mostrar as propriedades de uma Cache do Azure para Redis existente, utilize o seguinte comando:

    azure rediscache show [--name <name> --resource-group <resource-group>]

Para obter mais informações sobre este comando, execute o azure rediscache show -h comando .

C:\>azure rediscache show -h
help:    Show properties of an existing Azure Cache for Redis
help:
help:    Usage: rediscache show [--name <name> --resource-group <resource-group>]
help:
help:    Options:
help:      -h, --help                             output usage information
help:      -v, --verbose                          use verbose output
help:      -vv                                    more verbose with debug output
help:      --json                                 use json output
help:      -n, --name <name>                      Name of the Azure Cache for Redis.
help:      -g, --resource-group <resource-group>  Name of the Resource Group
help:      -s, --subscription <subscription>      the subscription identifier
help:
help:    Current Mode: arm (Azure Resource Management)

Alterar as definições de uma Cache do Azure para Redis existente

Para alterar as definições de uma Cache do Azure para Redis existente, utilize o seguinte comando:

    azure rediscache set [--name <name> --resource-group <resource-group> --redis-configuration <redis-configuration>/--redis-configuration-file <redisConfigurationFile>]

Para obter mais informações sobre este comando, execute o azure rediscache set -h comando .

C:\>azure rediscache set -h
help:    Change settings of an existing Azure Cache for Redis
help:
help:    Usage: rediscache set [--name <name> --resource-group <resource-group> --redis-configuration <redis-configuration>/--redis-configuration-file <redisConfigurationFile>]
help:
help:    Options:
help:      -h, --help                                               output usage information
help:      -v, --verbose                                            use verbose output
help:      -vv                                                      more verbose with debug output
help:      --json                                                   use json output
help:      -n, --name <name>                                        Name of the Azure Cache for Redis.
help:      -g, --resource-group <resource-group>                    Name of the Resource Group
help:      -c, --redis-configuration <redis-configuration>          Redis Configuration. Enter a JSON formatted string of configuration keys and values here.
help:      -f, --redis-configuration-file <redisConfigurationFile>  Redis Configuration. Enter the path of a file containing configuration keys and values here.
help:      -s, --subscription <subscription>                        the subscription identifier
help:
help:    Current Mode: arm (Azure Resource Management)

Renovar a chave de autenticação de uma Cache do Azure para Redis existente

Para renovar a chave de autenticação de um Cache do Azure para Redis existente, utilize o seguinte comando:

    azure rediscache renew-key [--name <name> --resource-group <resource-group> --key-type <key-type>]

Especifique Primary ou Secondary para key-type.

Para obter mais informações sobre este comando, execute o azure rediscache renew-key -h comando .

C:\>azure rediscache renew-key -h
help:    Renew the authentication key for an existing Azure Cache for Redis
help:
help:    Usage: rediscache renew-key [--name <name> --resource-group <resource-group> ]
help:
help:    Options:
help:      -h, --help                             output usage information
help:      -v, --verbose                          use verbose output
help:      -vv                                    more verbose with debug output
help:      --json                                 use json output
help:      -n, --name <name>                      Name of the Azure Cache for Redis.
help:      -g, --resource-group <resource-group>  Name of the Resource Group under which cache exists
help:      -t, --key-type <key-type>              type of key to renew. Valid values are: 'Primary', 'Secondary'.
help:      -s, --subscription <subscription>      the subscription identifier
help:
help:    Current Mode: arm (Azure Resource Management)

Listar chaves Primárias e Secundárias de um Cache do Azure para Redis existente

Para listar chaves primárias e secundárias de um Cache do Azure para Redis existente, utilize o seguinte comando:

    azure rediscache list-keys [--name <name> --resource-group <resource-group>]

Para obter mais informações sobre este comando, execute o azure rediscache list-keys -h comando .

C:\>azure rediscache list-keys -h
help:    Lists Primary and Secondary key of an existing Azure Cache for Redis
help:
help:    Usage: rediscache list-keys [--name <name> --resource-group <resource-group>]
help:
help:    Options:
help:      -h, --help                             output usage information
help:      -v, --verbose                          use verbose output
help:      -vv                                    more verbose with debug output
help:      --json                                 use json output
help:      -n, --name <name>                      Name of the Azure Cache for Redis.
help:      -g, --resource-group <resource-group>  Name of the Resource Group under which Cache exists
help:      -s, --subscription <subscription>      the subscription identifier
help:
help:    Current Mode: arm (Azure Resource Management)