Så här skapar och hanterar du Azure Cache for Redis med den klassiska Azure CLI

Det klassiska Azure CLI är ett bra sätt att hantera din Azure-infrastruktur från valfri plattform. Den här artikeln visar hur du skapar och hanterar dina Azure Cache for Redis-instanser med hjälp av klassiska Azure CLI.

Viktigt

Den här artikeln innehåller innehåll som kräver den klassiska Azure CLI. Det här är en äldre version av Azure CLI som endast bör användas med den klassiska Azure-distributionsmodellen.

Information om hur du installerar det klassiska CLI finns i Installera den klassiska Azure CLI och installera den aktuella Azure CLI för Azure Resource Manager distributioner finns i Installera Azure CLI.

Anteckning

De senaste Azure CLI-exempelskripten finns i Azure CLI Azure Cache for Redis exempel.

Förutsättningar

Om du vill skapa och hantera Azure Cache for Redis instanser med klassisk Azure CLI måste du utföra följande steg.

Egenskaper för Azure Cache for Redis

Följande egenskaper används när du skapar och uppdaterar Azure Cache for Redis instanser.

Egenskap Switch Beskrivning
name -n, --name Namnet på Azure Cache for Redis.
Resursgrupp -g, --resource-group Namnet på resursgruppen.
location -L, --location Plats för att skapa cache.
ikoner -z, --size Storleken på Azure Cache for Redis. Giltiga värden: [C0, C1, C2, C3, C4, C5, C6, P1, P2, P3, P4]
sku -x, --sku Redis SKU. Bör vara något av: [Basic, Standard, Premium]
EnableNonSslPort -e, --enable-non-ssl-port Egenskapen EnableNonSslPort för Azure Cache for Redis. Lägg till den här flaggan om du vill aktivera icke-TLS/SSL-porten för cacheminnet
Redis-konfiguration -c, --redis-configuration Redis-konfiguration. Ange en JSON-formaterad sträng med konfigurationsnycklar och värden här. Format:"{"":"","":""}"
Redis-konfiguration -f, --redis-configuration-file Redis-konfiguration. Ange sökvägen till en fil som innehåller konfigurationsnycklar och värden här. Format för filposten: {"":"","":""}
Antal shard -r, --shard-count Antal shards som ska skapas på en Premium-klustercache med klustring.
Virtual Network -v, --virtual-network När du är värd för din cache i ett virtuellt nätverk anger du exakt Resource Manager resurs-ID för det virtuella nätverket för att distribuera Azure Cache for Redis i. Exempelformat: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.ClassicNetwork/VirtualNetworks/vnet1
nyckeltyp -t, --key-type Typ av nyckel som ska förnyas. Giltiga värden: [Primär, Sekundär]
StaticIP -p, --static-ip <static-ip> När du är värd för din cache i ett virtuellt nätverk anger du en unik IP-adress i undernätet för cachen. Om det inte anges väljs en åt dig från undernätet.
Undernät t, --subnet <subnet> När du är värd för din cache i ett virtuellt nätverk anger du namnet på det undernät där cachen ska distribueras.
VirtualNetwork -v, --virtual-network <virtual-network> När du är värd för din cache i ett virtuellt nätverk anger du exakt Resource Manager resurs-ID för det virtuella nätverket för att distribuera Azure Cache for Redis i. Exempelformat: /subscriptions/{subid}/resourceGroups/{resourceGroupName}/Microsoft.ClassicNetwork/VirtualNetworks/vnet1
Prenumeration -s, --subscription Prenumerationsidentifieraren.

Visa alla Azure Cache for Redis kommandon

Om du vill se alla Azure Cache for Redis kommandon och deras parametrar använder du azure rediscache -h kommandot .

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)

Skapa en Azure Cache for Redis

Om du vill skapa en Azure Cache for Redis använder du följande kommando:

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

Kör kommandot om du vill ha mer information om det azure rediscache create -h här kommandot.

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)

Ta bort en befintlig Azure Cache for Redis

Om du vill ta bort en Azure Cache for Redis använder du följande kommando:

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

Kör kommandot om du vill ha mer information om det azure rediscache delete -h här kommandot.

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)

Visa en lista över alla Azure Cache for Redis i din prenumeration eller resursgrupp

Om du vill visa en lista över alla Azure Cache for Redis i din prenumeration eller resursgrupp använder du följande kommando:

    azure rediscache list [options]

Kör kommandot om du vill ha mer information om det azure rediscache list -h här kommandot.

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)

Visa egenskaper för en befintlig Azure Cache for Redis

Om du vill visa egenskaper för en befintlig Azure Cache for Redis använder du följande kommando:

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

Kör kommandot om du vill ha mer information om det azure rediscache show -h här kommandot.

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)

Ändra inställningar för en befintlig Azure Cache for Redis

Om du vill ändra inställningarna för en befintlig Azure Cache for Redis använder du följande kommando:

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

Kör kommandot om du vill ha mer information om det azure rediscache set -h här kommandot.

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)

Förnya autentiseringsnyckeln för en befintlig Azure Cache for Redis

Om du vill förnya autentiseringsnyckeln för en befintlig Azure Cache for Redis använder du följande kommando:

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

Ange Primary eller Secondary för key-type.

Kör kommandot om du vill ha mer information om det azure rediscache renew-key -h här kommandot.

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)

Lista primära och sekundära nycklar för en befintlig Azure Cache for Redis

Om du vill visa en lista över primära och sekundära nycklar för en befintlig Azure Cache for Redis använder du följande kommando:

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

Kör kommandot om du vill ha mer information om det azure rediscache list-keys -h här kommandot.

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)