Come creare e gestire Cache Redis di Azure tramite l'interfaccia della riga di comando di Azure (Azure CLI)How to create and manage Azure Redis Cache using the Azure Command-Line Interface (Azure CLI)

L'interfaccia della riga di comando di Azure è un ottimo modo di gestire l'infrastruttura di Azure da qualsiasi piattaforma.The Azure CLI is a great way to manage your Azure infrastructure from any platform. In questo articolo viene illustrato come creare e gestire le istanze di Cache Redis di Azure tramite la CLI di Azure.This article shows you how to create and manage your Azure Redis Cache instances using the Azure CLI.

Nota

Questo articolo si applica a una versione precedente dell'interfaccia della riga di comando di Azure.This article applies to a previous version of Azure CLI. Per script di esempio della più recente interfaccia della riga di comando di Azure 2.0, vedere gli esempi dell'interfaccia della riga di comando di Azure per Cache Redis.For the latest Azure CLI 2.0 sample scripts, see Azure CLI Redis cache samples.

PrerequisitiPrerequisites

Per creare e gestire le istanze di Cache Redis di Azure utilizzando CLI di Azure, è necessario completare i passaggi seguenti.To create and manage Azure Redis Cache instances using Azure CLI, you must complete the following steps.

Proprietà di Cache RedisRedis Cache properties

Le seguenti proprietà vengono utilizzate durante la creazione e l’aggiornamento delle istanze di Cache Redis.The following properties are used when creating and updating Redis Cache instances.

ProprietàProperty SwitchSwitch DescrizioneDescription
namename -n, --name-n, --name Nome della Cache Redis.Name of the Redis Cache.
gruppo di risorseresource group -g, --resource-group-g, --resource-group Nome del gruppo di risorse.Name of the Resource Group.
locationlocation -l, --location-l, --location Posizione in cui creare una cache.Location to create cache.
sizesize -z, --size-z, --size Dimensione della Cache Redis.Size of the Redis Cache. Valori validi: [C0, C1, C2, C3, C4, C5, C6, P1, P2, P3, P4]Valid values: [C0, C1, C2, C3, C4, C5, C6, P1, P2, P3, P4]
skusku -x, sku:-x, --sku SKU di Redis.Redis SKU. Deve essere uno di: [Basic, Standard, Premium]Should be one of : [Basic, Standard, Premium]
EnableNonSslPortEnableNonSslPort -e, --enable-non-ssl-port-e, --enable-non-ssl-port Proprietà EnableNonSslPort della Cache Redis.EnableNonSslPort property of the Redis Cache. Aggiungere questo flag se si desidera abilitare la porta SSL Non per la cacheAdd this flag if you want to enable the Non SSL Port for your cache
Configurazione di RedisRedis Configuration -c, --redis-configuration-c, --redis-configuration Configurazione di Redis.Redis Configuration. Immettere qui una stringa in formato JSON di chiavi di configurazione e valori.Enter a JSON formatted string of configuration keys and values here. Formato: "{"":"","":""}"Format:"{"":"","":""}"
Configurazione di RedisRedis Configuration -f, --redis-configuration-file-f, --redis-configuration-file Configurazione di Redis.Redis Configuration. Immettere qui il percorso di un file contenente le chiavi di configurazione e i valori.Enter the path of a file containing configuration keys and values here. Formato per l’immissione del file: {"": "","": ""}Format for the file entry: {"":"","":""}
Numero di partizioniShard Count -r, --shard-count-r, --shard-count Numero di partizioni da creare su una cache di cluster Premium con il clustering.Number of Shards to create on a Premium Cluster Cache with clustering.
Rete virtualeVirtual Network -v, --virtual-network-v, --virtual-network Quando si ospita la cache in una rete virtuale, specifica l'ID risorsa esatto ARM della rete virtuale in cui distribuire la cache Redis.When hosting your cache in a VNET, specifies the exact ARM resource ID of the virtual network to deploy the redis cache in. Formato di esempio: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.ClassicNetwork/VirtualNetworks/vnet1Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.ClassicNetwork/VirtualNetworks/vnet1
tipo di chiavekey type -t, --key-type-t, --key-type Tipo di chiave per il rinnovo.Type of key to renew. Valori validi: [primario, secondario]Valid values: [Primary, Secondary]
StaticIPStaticIP -p, --static-ip -p, --static-ip Quando si ospita la cache in una rete virtuale, specifica l'indirizzo IP univoco nella subnet per la cache.When hosting your cache in a VNET, specifies a unique IP address in the subnet for the cache. Se non specificato, ne verrà scelto uno dalla subnet.If not provided, one is chosen for you from the subnet.
SubnetSubnet t, --subnet t, --subnet Quando si ospita la cache in una rete virtuale, specifica il nome della subnet in cui distribuire la cache.When hosting your cache in a VNET, specifies the name of the subnet in which to deploy the cache.
VirtualNetworkVirtualNetwork -v, --virtual-network -v, --virtual-network Quando si ospita la cache in una rete virtuale, specifica l'ID risorsa esatto ARM della rete virtuale in cui distribuire la cache Redis.When hosting your cache in a VNET, specifies the exact ARM resource ID of the virtual network to deploy the redis cache in. Formato di esempio: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.ClassicNetwork/VirtualNetworks/vnet1Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.ClassicNetwork/VirtualNetworks/vnet1
SubscriptionSubscription -s, --subscription-s, --subscription L'identificatore della sottoscrizione.The subscription identifier.

Vedere tutti i comandi di Cache RedisSee all Redis Cache commands

Per visualizzare tutti i comandi di Cache Redis e i relativi parametri, utilizzare il comando azure rediscache -h .To see all Redis Cache commands and their parameters, use the azure rediscache -h command.

C:\>azure rediscache -h
help:    Commands to manage your Azure Redis Cache(s)
help:
help:    Create a Redis Cache
help:      rediscache create [--name <name> --resource-group <resource-group> --location <location> [options]]
help:
help:    Delete an existing Redis Cache
help:      rediscache delete [--name <name> --resource-group <resource-group> ]
help:
help:    List all Redis Caches within your Subscription or Resource Group
help:      rediscache list [options]
help:
help:    Show properties of an existing Redis Cache
help:      rediscache show [--name <name> --resource-group <resource-group>]
help:
help:    Change settings of an existing Redis Cache
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 Redis Cache
help:      rediscache renew-key [--name <name> --resource-group <resource-group> ]
help:
help:    Lists Primary and Secondary key of an existing Redis Cache
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)

Creare una Cache RedisCreate a Redis Cache

Per creare una Cache Redis, utilizzare il comando seguente:To create a Redis Cache, use the following command:

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

Per altre informazioni su questo comando, eseguire il comando azure rediscache create -h .For more information about this command, run the azure rediscache create -h command.

C:\>azure rediscache create -h
help:    Create a Redis Cache
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 Redis Cache.
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 Redis Cache. 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 Redis Cache. Add this flag if you want to enable the Non 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 redis cache in. Example format: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.ClassicNetwork/VirtualNetworks/vnet1
help:      -t, --subnet <subnet>                                    Required when deploying a redis cache inside an existing Azure Virtual Network
help:      -p, --static-ip <static-ip>                              Required when deploying a redis cache inside an existing Azure Virtual Network
help:      -s, --subscription <id>                                  the subscription identifier
help:
help:    Current Mode: arm (Azure Resource Management)

Eliminare una Cache Redis esistenteDelete an existing Redis Cache

Per eliminare una Cache Redis, utilizzare il comando seguente:To delete a Redis Cache, use the following command:

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

Per altre informazioni su questo comando, eseguire il comando azure rediscache delete -h .For more information about this command, run the azure rediscache delete -h command.

C:\>azure rediscache delete -h
help:    Delete an existing Redis Cache
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 Redis Cache.
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)

Elenco di tutte le Cache Redis all'interno della sottoscrizione o di un gruppo di risorseList all Redis Caches within your Subscription or Resource Group

Per elencare tutte le Cache Redis all'interno della sottoscrizione o un gruppo di risorse, utilizzare il comando seguente:To list all Redis Caches within your Subscription or Resource Group, use the following command:

azure rediscache list [options]

Per altre informazioni su questo comando, eseguire il comando azure rediscache list -h .For more information about this command, run the azure rediscache list -h command.

C:\>azure rediscache list -h
help:    List all Redis Caches 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)

Visualizzare le proprietà di una Cache Redis esistenteShow properties of an existing Redis Cache

Per visualizzare le proprietà di una Cache Redis esistente, utilizzare il comando seguente:To show properties of an existing Redis Cache, use the following command:

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

Per altre informazioni su questo comando, eseguire il comando azure rediscache show -h .For more information about this command, run the azure rediscache show -h command.

C:\>azure rediscache show -h
help:    Show properties of an existing Redis Cache
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 Redis Cache.
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)

Modificare le impostazioni di una Cache Redis esistenteChange settings of an existing Redis Cache

Per modificare le impostazioni di una Cache Redis esistente, utilizzare il comando seguente:To change settings of an existing Redis Cache, use the following command:

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

Per altre informazioni su questo comando, eseguire il comando azure rediscache set -h .For more information about this command, run the azure rediscache set -h command.

C:\>azure rediscache set -h
help:    Change settings of an existing Redis Cache
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 Redis Cache.
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)

Rinnovare la chiave di autenticazione per una Cache Redis esistenteRenew the authentication key for an existing Redis Cache

Per rinnovare la chiave di autenticazione per una Cache Redis esistente, utilizzare il comando seguente:To renew the authentication key for an existing Redis Cache, use the following command:

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

Specificare Primary o Secondary per key-type.Specify Primary or Secondary for key-type.

Per altre informazioni su questo comando, eseguire il comando azure rediscache renew-key -h.For more information about this command, run the azure rediscache renew-key -h command.

C:\>azure rediscache renew-key -h
help:    Renew the authentication key for an existing Redis Cache
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 Redis Cache.
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)

Chiavi di elenco primario e secondario di una Cache Redis esistenteList Primary and Secondary keys of an existing Redis Cache

Per le chiavi di elenco primario o secondario di una Cache Redis esistente, utilizzare il comando seguente:To list Primary and Secondary keys of an existing Redis Cache, use the following command:

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

Per altre informazioni su questo comando, eseguire il comando azure rediscache list-keys -h .For more information about this command, run the azure rediscache list-keys -h command.

C:\>azure rediscache list-keys -h
help:    Lists Primary and Secondary key of an existing Redis Cache
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 Redis Cache.
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)