Hantera Azure Cache for Redis med Azure PowerShell

Den här artikeln visar hur du skapar, uppdaterar och skalar dina Azure Cache for Redis-instanser. Artikeln visar också hur du återskapar åtkomstnycklar och hur du visar information om dina cacheminnen. En fullständig lista över Azure Cache for Redis PowerShell-cmdletar finns i Azure Cache for Redis-cmdletar.

Kommentar

Azure har två olika distributionsmodeller som du kan använda för att skapa och arbeta med resurser: Azure Resource Manager och klassisk. Den här artikeln beskriver användningen av Resource Manager-distributionsmodellen. Vi rekommenderar Resource Manager-distributionsmodellen för nya distributioner i stället för den klassiska distributionsmodellen.

Mer information om den klassiska distributionsmodellen finns i Azure Resource Manager jämfört med klassisk distribution: Förstå distributionsmodeller och tillståndet för dina resurser.

Förutsättningar

Om du redan har installerat Azure PowerShell måste du ha Azure PowerShell version 1.0.0 eller senare. Du kan kontrollera versionen av Azure PowerShell med det här kommandot i Azure PowerShell-kommandotolken.

    Get-Module Az | format-table version

Först måste du logga in på Azure med det här kommandot.

    Connect-AzAccount

Ange e-postadressen för ditt Azure-konto och ditt lösenord i microsoft Azure-inloggningsdialogrutan.

Om du sedan har flera Azure-prenumerationer måste du ange din Azure-prenumeration. Om du vill se en lista över dina aktuella prenumerationer kör du det här kommandot.

    Get-AzSubscription | sort SubscriptionName | Select SubscriptionName

Om du vill ange prenumerationen kör du följande kommando. I följande exempel är ContosoSubscriptionprenumerationsnamnet .

    Select-AzSubscription -SubscriptionName ContosoSubscription

Innan du kan använda Windows PowerShell med Azure Resource Manager måste du kontrollera konfigurationen:

  • Windows PowerShell, version 3.0 eller 4.0. Om du vill hitta versionen av Windows PowerShell skriver du:$PSVersionTable och kontrollerar att värdet PSVersion för är 3.0 eller 4.0. Information om hur du installerar en kompatibel version finns i Windows Management Framework 3.0.

Om du vill få detaljerad hjälp för alla cmdletar som du ser i den här självstudien använder du cmdleten Get-Help.

    Get-Help <cmdlet-name> -Detailed

Om du till exempel vill få hjälp med cmdleten New-AzRedisCache skriver du:

    Get-Help New-AzRedisCache -Detailed

Ansluta till andra moln

Som standard är AzureCloudAzure-miljön , som representerar den globala Azure-molninstansen. Om du vill ansluta till en annan instans använder Connect-AzAccount du kommandot med -Environment kommandoradsväxeln eller medEnvironmentName det miljö- eller miljönamn som du vill använda.

Om du vill se listan över tillgängliga miljöer kör du cmdleten Get-AzEnvironment .

Ansluta till Azure Government Cloud

Om du vill ansluta till Azure Government Cloud använder du något av följande kommandon.

    Connect-AzAccount -EnvironmentName AzureUSGovernment

Eller

    Connect-AzAccount -Environment (Get-AzEnvironment -Name AzureUSGovernment)

Om du vill skapa en cache i Azure Government Cloud använder du någon av följande platser.

  • USGov Virginia
  • USGov Iowa

Mer information om Azure Government Cloud finns i Utvecklarguide för Microsoft Azure Government och Microsoft Azure Government.

Ansluta till Microsoft Azure som drivs av 21Vianet Cloud

Om du vill ansluta till Azure som drivs av 21Vianet-molnet använder du något av följande kommandon.

    Connect-AzAccount -EnvironmentName AzureChinaCloud

Eller

    Connect-AzAccount -Environment (Get-AzEnvironment -Name AzureChinaCloud)

Om du vill skapa en cache i Azure som drivs av 21Vianet Cloud använder du någon av följande platser.

  • Kina, östra
  • Kina, norra

Ansluta till Microsoft Azure Tyskland

Om du vill ansluta till Microsoft Azure Tyskland använder du något av följande kommandon.

    Connect-AzAccount -EnvironmentName AzureGermanCloud

Eller

    Connect-AzAccount -Environment (Get-AzEnvironment -Name AzureGermanCloud)

Om du vill skapa en cache i Microsoft Azure Tyskland använder du någon av följande platser.

  • Tyskland, centrala
  • Tyskland, nordöstra

Mer information om Microsoft Azure Tyskland finns i Microsoft Azure Tyskland.

Egenskaper som används för Azure Cache for Redis PowerShell

Följande tabell innehåller Azure PowerShell-egenskaper och beskrivningar för vanliga parametrar när du skapar och hanterar dina Azure Cache for Redis-instanser.

Parameter Description Standard
Name Namnet på cachen
Plats Platsen för cachen
ResourceGroupName Namn på resursgrupp där cacheminnet ska skapas
Storlek Cachens storlek. Giltiga värden är: P1, P2, P3, P4, P5, C0, C1, C2, C3, C4, C5, C6, 250MB, 1GB, 2.5GB, 6GB, 13GB, 26GB, 53GB 1 GB
ShardCount Antalet shards som ska skapas när du skapar en Premium-cache med klustring aktiverat. Giltiga värden är: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
SKU Anger SKU:n för cacheminnet. Giltiga värden är: Basic, Standard, Premium Standard
RedisConfiguration Anger Redis-konfigurationsinställningar. Mer information om varje inställning finns i följande redisConfiguration-egenskapstabell .
EnableNonSslPort Anger om icke-SSL-porten är aktiverad. Falsk
MaxMemoryPolicy Den här parametern har blivit inaktuell – använd RedisConfiguration i stället.
StaticIP 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 När du är värd för din cache i ett virtuellt nätverk anger du namnet på det undernät som cachen ska distribueras i.
VirtualNetwork När du är värd för din cache i ett virtuellt nätverk anger du resurs-ID för det virtuella nätverk där cachen ska distribueras.
Keytype Anger vilken åtkomstnyckel som ska återskapas när åtkomstnycklar förnyas. Giltiga värden är: Primär, Sekundär

RedisConfiguration-egenskaper

Property beskrivning Prisnivåer
rdb-backup-enabled Om Redis-datapersistence är aktiverat Endast Premium
rdb-storage-connection-string Anslutningssträng till lagringskontot för Redis-datapersistence Endast Premium
rdb-backup-frequency Säkerhetskopieringsfrekvensen för Redis-datapersistence Endast Premium
maxmemory-reserved Konfigurerar minnet som är reserverat för processer som inte är cachelagrade Standard och Premium
maxmemory-policy Konfigurerar borttagningsprincipen för cacheminnet Alla prisnivåer
notify-keyspace-events Konfigurerar keyspace-meddelanden Standard och Premium
hash-max-ziplist-entries Konfigurerar minnesoptimering för små mängddatatyper Standard och Premium
hash-max-ziplist-value Konfigurerar minnesoptimering för små mängddatatyper Standard och Premium
set-max-intset-entries Konfigurerar minnesoptimering för små mängddatatyper Standard och Premium
zset-max-ziplist-entries Konfigurerar minnesoptimering för små mängddatatyper Standard och Premium
zset-max-ziplist-value Konfigurerar minnesoptimering för små mängddatatyper Standard och Premium
databaser Konfigurerar antalet databaser. Den här egenskapen kan endast konfigureras när cacheminnet skapas. Standard och Premium

Så här skapar du en Azure Cache for Redis

Nya Azure Cache for Redis-instanser skapas med cmdleten New-AzRedisCache .

Viktigt!

Första gången du skapar en Azure Cache for Redis i en prenumeration med azure-portalen registrerar portalen namnområdet för den prenumerationen Microsoft.Cache . Om du försöker skapa den första Azure Cache for Redis i en prenumeration med Hjälp av PowerShell måste du först registrera namnområdet med hjälp av följande kommando. annars cmdletar som New-AzRedisCache och Get-AzRedisCache misslyckas.

Register-AzResourceProvider -ProviderNamespace "Microsoft.Cache"

Om du vill se en lista över tillgängliga parametrar och deras beskrivningar för New-AzRedisCachekör du följande kommando.

    PS C:\> Get-Help New-AzRedisCache -detailed

    NAME
        New-AzRedisCache

    SYNOPSIS
        Creates a new Azure Cache for Redis.


    SYNTAX
        New-AzRedisCache -Name <String> -ResourceGroupName <String> -Location <String> [-RedisVersion <String>]
        [-Size <String>] [-Sku <String>] [-MaxMemoryPolicy <String>] [-RedisConfiguration <Hashtable>] [-EnableNonSslPort
        <Boolean>] [-ShardCount <Integer>] [-VirtualNetwork <String>] [-Subnet <String>] [-StaticIP <String>]
        [<CommonParameters>]


    DESCRIPTION
        The New-AzRedisCache cmdlet creates a new Azure Cache for Redis.


    PARAMETERS
        -Name <String>
            Name of the Azure Cache for Redis to create.

        -ResourceGroupName <String>
            Name of resource group in which to create the Azure Cache for Redis.

        -Location <String>
            Location in which to create the Azure Cache for Redis.

        -RedisVersion <String>
            RedisVersion is deprecated and will be removed in future release.

        -Size <String>
            Size of the Azure Cache for Redis. The default value is 1GB or C1. Possible values are P1, P2, P3, P4, C0, C1, C2, C3,
            C4, C5, C6, 250MB, 1GB, 2.5GB, 6GB, 13GB, 26GB, 53GB.

        -Sku <String>
            Sku of Azure Cache for Redis. The default value is Standard. Possible values are Basic, Standard and Premium.

        -MaxMemoryPolicy <String>
            The 'MaxMemoryPolicy' setting has been deprecated. Please use 'RedisConfiguration' setting to set
            MaxMemoryPolicy. e.g. -RedisConfiguration @{"maxmemory-policy" = "allkeys-lru"}

        -RedisConfiguration <Hashtable>
            All Redis Configuration Settings. Few possible keys: rdb-backup-enabled, rdb-storage-connection-string,
            rdb-backup-frequency, maxmemory-reserved, maxmemory-policy, notify-keyspace-events, hash-max-ziplist-entries,
            hash-max-ziplist-value, set-max-intset-entries, zset-max-ziplist-entries, zset-max-ziplist-value, databases.

        -EnableNonSslPort <Boolean>
            EnableNonSslPort is used by Azure Cache for Redis. If no value is provided, the default value is false and the
            non-SSL port will be disabled. Possible values are true and false.

        -ShardCount <Integer>
            The number of shards to create on a Premium Cluster Cache.

        -VirtualNetwork <String>
            The exact ARM resource ID of the virtual network to deploy the Azure Cache for Redis in. Example format: /subscriptions/{
            subid}/resourceGroups/{resourceGroupName}/providers/Microsoft.ClassicNetwork/VirtualNetworks/{vnetName}

        -Subnet <String>
            Required when deploying an Azure Cache for Redis inside an existing Azure Virtual Network.

        -StaticIP <String>
            Required when deploying an Azure Cache for Redis inside an existing Azure Virtual Network.

        <CommonParameters>
            This cmdlet supports the common parameters: Verbose, Debug,
            ErrorAction, ErrorVariable, WarningAction, WarningVariable,
            OutBuffer, PipelineVariable, and OutVariable. For more information, see
            about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

Kör följande kommando för att skapa en cache med standardparametrar.

    New-AzRedisCache -ResourceGroupName myGroup -Name mycache -Location "North Central US"

ResourceGroupName, Name, och Location är obligatoriska parametrar, men resten är valfria och har standardvärden. När du kör föregående kommando skapas en Standard SKU Azure Cache for Redis-instans med det angivna namnet, platsen och resursgruppen. Instansen är 1 GB i storlek med icke-SSL-porten inaktiverad.

Om du vill skapa en Premium-cache anger du storleken P1 (6 GB – 60 GB), P2 (13 GB – 130 GB), P3 (26 GB – 260 GB) eller P4 (53 GB – 530 GB). Om du vill aktivera klustring anger du ett shardantal med hjälp av parametern ShardCount . I följande exempel skapas en P1 Premium-cache med tre shards. En P1 Premium-cache är 6 GB stor och eftersom vi har angett tre shards är den totala storleken 18 GB (3 x 6 GB).

    New-AzRedisCache -ResourceGroupName myGroup -Name mycache -Location "North Central US" -Sku Premium -Size P1 -ShardCount 3

Om du vill ange värden för parametern RedisConfiguration omger du värdena inuti {} som nyckel/värde-par som @{"maxmemory-policy" = "allkeys-random", "notify-keyspace-events" = "KEA"}. I följande exempel skapas en standardcache på 1 GB med allkeys-random maxmemory-princip- och keyspace-meddelanden som konfigurerats med KEA. Mer information finns i Keyspace-meddelanden (avancerade inställningar) och Minnesprinciper.

    New-AzRedisCache -ResourceGroupName myGroup -Name mycache -Location "North Central US" -RedisConfiguration @{"maxmemory-policy" = "allkeys-random", "notify-keyspace-events" = "KEA"}

Så här konfigurerar du databasinställningen när cacheminnet skapas

Inställningen databases kan endast konfigureras när cacheminnet skapas. I följande exempel skapas en Premium P3-cache (26 GB) med 48 databaser med cmdleten New-AzRedisCache .

    New-AzRedisCache -ResourceGroupName myGroup -Name mycache -Location "North Central US" -Sku Premium -Size P3 -RedisConfiguration @{"databases" = "48"}

Mer information om egenskapen finns i Standardkonfiguration för databases Azure Cache for Redis-server. Mer information om hur du skapar en cache med hjälp av cmdleten New-AzRedisCache finns i föregående avsnitt Om du vill skapa en Azure Cache for Redis.

Uppdatera en Azure Cache for Redis

Azure Cache for Redis-instanser uppdateras med hjälp av cmdleten Set-AzRedisCache .

Om du vill se en lista över tillgängliga parametrar och deras beskrivningar för Set-AzRedisCachekör du följande kommando.

    PS C:\> Get-Help Set-AzRedisCache -detailed

    NAME
        Set-AzRedisCache

    SYNOPSIS
        Set Azure Cache for Redis updatable parameters.

    SYNTAX
        Set-AzRedisCache -Name <String> -ResourceGroupName <String> [-Size <String>] [-Sku <String>]
        [-MaxMemoryPolicy <String>] [-RedisConfiguration <Hashtable>] [-EnableNonSslPort <Boolean>] [-ShardCount
        <Integer>] [<CommonParameters>]

    DESCRIPTION
        The Set-AzRedisCache cmdlet sets Azure Cache for Redis parameters.

    PARAMETERS
        -Name <String>
            Name of the Azure Cache for Redis to update.

        -ResourceGroupName <String>
            Name of the resource group for the cache.

        -Size <String>
            Size of the Azure Cache for Redis. The default value is 1GB or C1. Possible values are P1, P2, P3, P4, C0, C1, C2, C3,
            C4, C5, C6, 250MB, 1GB, 2.5GB, 6GB, 13GB, 26GB, 53GB.

        -Sku <String>
            Sku of Azure Cache for Redis. The default value is Standard. Possible values are Basic, Standard and Premium.

        -MaxMemoryPolicy <String>
            The 'MaxMemoryPolicy' setting has been deprecated. Please use 'RedisConfiguration' setting to set
            MaxMemoryPolicy. e.g. -RedisConfiguration @{"maxmemory-policy" = "allkeys-lru"}

        -RedisConfiguration <Hashtable>
            All Redis Configuration Settings. Few possible keys: rdb-backup-enabled, rdb-storage-connection-string,
            rdb-backup-frequency, maxmemory-reserved, maxmemory-policy, notify-keyspace-events, hash-max-ziplist-entries,
            hash-max-ziplist-value, set-max-intset-entries, zset-max-ziplist-entries, zset-max-ziplist-value.

        -EnableNonSslPort <Boolean>
            EnableNonSslPort is used by Azure Cache for Redis. The default value is null and no change will be made to the
            currently configured value. Possible values are true and false.

        -ShardCount <Integer>
            The number of shards to create on a Premium Cluster Cache.

        <CommonParameters>
            This cmdlet supports the common parameters: Verbose, Debug,
            ErrorAction, ErrorVariable, WarningAction, WarningVariable,
            OutBuffer, PipelineVariable, and OutVariable. For more information, see
            about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

Cmdleten Set-AzRedisCache kan användas för att uppdatera egenskaper som Size, Sku, EnableNonSslPortoch RedisConfiguration värdena.

Följande kommando uppdaterar maxmemory-policyn för Azure Cache for Redis med namnet myCache.

    Set-AzRedisCache -ResourceGroupName "myGroup" -Name "myCache" -RedisConfiguration @{"maxmemory-policy" = "allkeys-random"}

Skala en Azure Cache for Redis

Set-AzRedisCache kan användas för att skala en Azure Cache for Redis-instans när Sizeegenskaperna , Skueller ShardCount ändras.

Kommentar

Skalning av en cache med PowerShell omfattas av samma gränser och riktlinjer som skalning av en cache från Azure-portalen. Du kan skala till en annan prisnivå med följande begränsningar.

  • Du kan inte skala från en högre prisnivå till en lägre prisnivå.
  • Du kan inte skala från en Premium-cache till en Standard- eller Basic-cache.
  • Du kan inte skala från en Standard-cache till en Basic-cache .
  • Du kan skala från en Basic-cache till en Standard-cache , men du kan inte ändra storleken på samma gång. Om du behöver en annan storlek kan du utföra en efterföljande skalningsåtgärd till önskad storlek.
  • Du kan inte skala från en Basic-cache direkt till en Premium-cache . Du måste skala från Basic till Standard i en skalningsåtgärd och sedan från Standard till Premium i en efterföljande skalningsåtgärd.
  • Du kan inte skala från en större storlek ned till storleken C0 (250 MB).

Mer information finns i Skala Azure Cache for Redis.

I följande exempel visas hur du skalar en cache med namnet myCache till en cache på 2,5 GB. Det här kommandot fungerar för både en Basic- eller Standard-cache.

    Set-AzRedisCache -ResourceGroupName myGroup -Name myCache -Size 2.5GB

När det här kommandot har utfärdats returneras statusen för cacheminnet---similar till anropet Get-AzRedisCache. ProvisioningState är inställt på Scaling.

    PS C:\> Set-AzRedisCache -Name myCache -ResourceGroupName myGroup -Size 2.5GB


    Name               : mycache
    Id                 : /subscriptions/12ad12bd-abdc-2231-a2ed-a2b8b246bbad4/resourceGroups/mygroup/providers/Mi
                         crosoft.Cache/Redis/mycache
    Location           : South Central US
    Type               : Microsoft.Cache/Redis
    HostName           : mycache.redis.cache.windows.net
    Port               : 6379
    ProvisioningState  : Scaling
    SslPort            : 6380
    RedisConfiguration : {[maxmemory-policy, volatile-lru], [maxmemory-reserved, 150], [notify-keyspace-events, KEA],
                         [maxmemory-delta, 150]...}
    EnableNonSslPort   : False
    RedisVersion       : 3.0
    Size               : 1GB
    Sku                : Standard
    ResourceGroupName  : mygroup
    PrimaryKey         : ....
    SecondaryKey       : ....
    VirtualNetwork     :
    Subnet             :
    StaticIP           :
    TenantSettings     : {}
    ShardCount         :

När skalningsåtgärden är klar ändras till ProvisioningStateSucceeded. Om du behöver göra en annan skalningsåtgärd--- till exempel ändra från Basic till Standard och sedan ändra storlek--- måste du vänta tills den föregående åtgärden har slutförts eller så får du ett fel som liknar följande.

    Set-AzRedisCache : Conflict: The resource '...' is not in a stable state, and is currently unable to accept the update request.

Så här hämtar du information om en Azure Cache for Redis

Du kan hämta information om en cache med hjälp av cmdleten Get-AzRedisCache .

Om du vill se en lista över tillgängliga parametrar och deras beskrivningar för Get-AzRedisCachekör du följande kommando.

    PS C:\> Get-Help Get-AzRedisCache -detailed

    NAME
        Get-AzRedisCache

    SYNOPSIS
        Gets details about a single cache or all caches in the specified resource group or all caches in the current
        subscription.

    SYNTAX
        Get-AzRedisCache [-Name <String>] [-ResourceGroupName <String>] [<CommonParameters>]

    DESCRIPTION
        The Get-AzRedisCache cmdlet gets the details about a cache or caches depending on input parameters. If both
        ResourceGroupName and Name parameters are provided then Get-AzRedisCache will return details about the
        specific cache name provided.

        If only ResourceGroupName is provided than it will return details about all caches in the specified resource group.

        If no parameters are given than it will return details about all caches the current subscription.

    PARAMETERS
        -Name <String>
            The name of the cache. When this parameter is provided along with ResourceGroupName, Get-AzRedisCache
            returns the details for the cache.

        -ResourceGroupName <String>
            The name of the resource group that contains the cache or caches. If ResourceGroupName is provided with Name
            then Get-AzRedisCache returns the details of the cache specified by Name. If only the ResourceGroup
            parameter is provided, then details for all caches in the resource group are returned.

        <CommonParameters>
            This cmdlet supports the common parameters: Verbose, Debug,
            ErrorAction, ErrorVariable, WarningAction, WarningVariable,
            OutBuffer, PipelineVariable, and OutVariable. For more information, see
            about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

Om du vill returnera information om alla cacheminnen i den aktuella prenumerationen kör du Get-AzRedisCache utan parametrar.

    Get-AzRedisCache

Om du vill returnera information om alla cacheminnen i en specifik resursgrupp kör du Get-AzRedisCache med parametern ResourceGroupName .

    Get-AzRedisCache -ResourceGroupName myGroup

Om du vill returnera information om en specifik cache kör Get-AzRedisCache du med parametern Name som innehåller namnet på cachen och parametern ResourceGroupName med resursgruppen som innehåller cacheminnet.

    PS C:\> Get-AzRedisCache -Name myCache -ResourceGroupName myGroup

    Name               : mycache
    Id                 : /subscriptions/12ad12bd-abdc-2231-a2ed-a2b8b246bbad4/resourceGroups/myGroup/providers/Mi
                         crosoft.Cache/Redis/mycache
    Location           : South Central US
    Type               : Microsoft.Cache/Redis
    HostName           : mycache.redis.cache.windows.net
    Port               : 6379
    ProvisioningState  : Succeeded
    SslPort            : 6380
    RedisConfiguration : {[maxmemory-policy, volatile-lru], [maxmemory-reserved, 62], [notify-keyspace-events, KEA],
                         [maxclients, 1000]...}
    EnableNonSslPort   : False
    RedisVersion       : 3.0
    Size               : 1GB
    Sku                : Standard
    ResourceGroupName  : myGroup
    VirtualNetwork     :
    Subnet             :
    StaticIP           :
    TenantSettings     : {}
    ShardCount         :

Hämta åtkomstnycklarna för en Azure Cache for Redis

Om du vill hämta åtkomstnycklarna för cacheminnet kan du använda cmdleten Get-AzRedisCacheKey .

Om du vill se en lista över tillgängliga parametrar och deras beskrivningar för Get-AzRedisCacheKeykör du följande kommando.

    PS C:\> Get-Help Get-AzRedisCacheKey -detailed

    NAME
        Get-AzRedisCacheKey

    SYNOPSIS
        Gets the accesskeys for the specified Azure Cache for Redis.


    SYNTAX
        Get-AzRedisCacheKey -Name <String> -ResourceGroupName <String> [<CommonParameters>]

    DESCRIPTION
        The Get-AzRedisCacheKey cmdlet gets the access keys for the specified cache.

    PARAMETERS
        -Name <String>
            Name of the Azure Cache for Redis.

        -ResourceGroupName <String>
            Name of the resource group for the cache.

        <CommonParameters>
            This cmdlet supports the common parameters: Verbose, Debug,
            ErrorAction, ErrorVariable, WarningAction, WarningVariable,
            OutBuffer, PipelineVariable, and OutVariable. For more information, see
            about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

Om du vill hämta nycklarna för cacheminnet anropar du cmdleten Get-AzRedisCacheKey och skickar namnet på cachen till namnet på den resursgrupp som innehåller cacheminnet.

    PS C:\> Get-AzRedisCacheKey -Name myCache -ResourceGroupName myGroup

    PrimaryKey   : b2wdt43sfetlju4hfbryfnregrd9wgIcc6IA3zAO1lY=
    SecondaryKey : ABhfB757JgjIgt785JgKH9865eifmekfnn649303JKL=

Återskapa åtkomstnycklar för Azure Cache for Redis

Om du vill återskapa åtkomstnycklarna för cacheminnet kan du använda cmdleten New-AzRedisCacheKey .

Om du vill se en lista över tillgängliga parametrar och deras beskrivningar för New-AzRedisCacheKeykör du följande kommando.

    PS C:\> Get-Help New-AzRedisCacheKey -detailed

    NAME
        New-AzRedisCacheKey

    SYNOPSIS
        Regenerates the access key of an Azure Cache for Redis.

    SYNTAX
        New-AzRedisCacheKey -Name <String> -ResourceGroupName <String> -KeyType <String> [-Force] [<CommonParameters>]

    DESCRIPTION
        The New-AzRedisCacheKey cmdlet regenerate the access key of an Azure Cache for Redis.

    PARAMETERS
        -Name <String>
            Name of the Azure Cache for Redis.

        -ResourceGroupName <String>
            Name of the resource group for the cache.

        -KeyType <String>
            Specifies whether to regenerate the primary or secondary access key. Possible values are Primary or Secondary.

        -Force
            When the Force parameter is provided, the specified access key is regenerated without any confirmation prompts.

        <CommonParameters>
            This cmdlet supports the common parameters: Verbose, Debug,
            ErrorAction, ErrorVariable, WarningAction, WarningVariable,
            OutBuffer, PipelineVariable, and OutVariable. For more information, see
            about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

Om du vill återskapa den primära eller sekundära nyckeln för cacheminnet anropar du cmdleten New-AzRedisCacheKey och skickar in namnet, resursgruppen och anger antingen Primary eller Secondary för parametern KeyType . I följande exempel återskapas den sekundära åtkomstnyckeln för en cache.

    PS C:\> New-AzRedisCacheKey -Name myCache -ResourceGroupName myGroup -KeyType Secondary

    Confirm
    Are you sure you want to regenerate Secondary key for Azure Cache for Redis 'myCache'?
    [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y


    PrimaryKey   : b2wdt43sfetlju4hfbryfnregrd9wgIcc6IA3zAO1lY=
    SecondaryKey : c53hj3kh4jhHjPJk8l0jji785JgKH9865eifmekfnn6=

Ta bort en Azure Cache for Redis

Om du vill ta bort en Azure Cache for Redis använder du cmdleten Remove-AzRedisCache .

Om du vill se en lista över tillgängliga parametrar och deras beskrivningar för Remove-AzRedisCachekör du följande kommando.

    PS C:\> Get-Help Remove-AzRedisCache -detailed

    NAME
        Remove-AzRedisCache

    SYNOPSIS
        Remove Azure Cache for Redis if exists.

    SYNTAX
        Remove-AzRedisCache -Name <String> -ResourceGroupName <String> [-Force] [-PassThru] [<CommonParameters>

    DESCRIPTION
        The Remove-AzRedisCache cmdlet removes an Azure Cache for Redis if it exists.

    PARAMETERS
        -Name <String>
            Name of the Azure Cache for Redis to remove.

        -ResourceGroupName <String>
            Name of the resource group of the cache to remove.

        -Force
            When the Force parameter is provided, the cache is removed without any confirmation prompts.

        -PassThru
            By default Remove-AzRedisCache removes the cache and does not return any value. If the PassThru par
            is provided then Remove-AzRedisCache returns a boolean value indicating the success of the operatio

        <CommonParameters>
            This cmdlet supports the common parameters: Verbose, Debug,
            ErrorAction, ErrorVariable, WarningAction, WarningVariable,
            OutBuffer, PipelineVariable, and OutVariable. For more information, see
            about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

I följande exempel tas cachen med namnet myCache bort.

    PS C:\> Remove-AzRedisCache -Name myCache -ResourceGroupName myGroup

    Confirm
    Are you sure you want to remove Azure Cache for Redis 'myCache'?
    [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y

Importera en Azure Cache for Redis

Du kan importera data till en Azure Cache for Redis-instans med hjälp av cmdleten Import-AzRedisCache .

Viktigt!

Import/export är endast tillgängligt för Premium-nivåcacheminnen . Mer information om import/export finns i Importera och exportera data i Azure Cache for Redis.

Om du vill se en lista över tillgängliga parametrar och deras beskrivningar för Import-AzRedisCachekör du följande kommando.

    PS C:\> Get-Help Import-AzRedisCache -detailed

    NAME
        Import-AzRedisCache

    SYNOPSIS
        Import data from blobs to Azure Cache for Redis.


    SYNTAX
        Import-AzRedisCache -Name <String> -ResourceGroupName <String> -Files <String[]> [-Format <String>] [-Force]
        [-PassThru] [<CommonParameters>]


    DESCRIPTION
        The Import-AzRedisCache cmdlet imports data from the specified blobs into Azure Cache for Redis.


    PARAMETERS
        -Name <String>
            The name of the cache.

        -ResourceGroupName <String>
            The name of the resource group that contains the cache.

        -Files <String[]>
            SAS urls of blobs whose content should be imported into the cache.

        -Format <String>
            Format for the blob.  Currently "rdb" is the only supported, with other formats expected in the future.

        -Force
            When the Force parameter is provided, import will be performed without any confirmation prompts.

        -PassThru
            By default Import-AzRedisCache imports data in cache and does not return any value. If the PassThru
            parameter is provided then Import-AzRedisCache returns a boolean value indicating the success of the
            operation.

        <CommonParameters>
            This cmdlet supports the common parameters: Verbose, Debug,
            ErrorAction, ErrorVariable, WarningAction, WarningVariable,
            OutBuffer, PipelineVariable, and OutVariable. For more information, see
            about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

Följande kommando importerar data från bloben som anges av SAS-URI:n till Azure Cache for Redis.

    PS C:\>Import-AzRedisCache -ResourceGroupName "resourceGroupName" -Name "cacheName" -Files @("https://mystorageaccount.blob.core.windows.net/mycontainername/blobname?sv=2015-04-05&sr=b&sig=caIwutG2uDa0NZ8mjdNJdgOY8%2F8mhwRuGNdICU%2B0pI4%3D&st=2016-05-27T00%3A00%3A00Z&se=2016-05-28T00%3A00%3A00Z&sp=rwd") -Force

Så här exporterar du en Azure Cache for Redis

Du kan exportera data från en Azure Cache for Redis-instans med hjälp av cmdleten Export-AzRedisCache .

Viktigt!

Import/export är endast tillgängligt för Premium-nivåcacheminnen . Mer information om import/export finns i Importera och exportera data i Azure Cache for Redis.

Om du vill se en lista över tillgängliga parametrar och deras beskrivningar för Export-AzRedisCachekör du följande kommando.

    PS C:\> Get-Help Export-AzRedisCache -detailed

    NAME
        Export-AzRedisCache

    SYNOPSIS
        Exports data from Azure Cache for Redis to a specified container.


    SYNTAX
        Export-AzRedisCache -Name <String> -ResourceGroupName <String> -Prefix <String> -Container <String> [-Format
        <String>] [-PassThru] [<CommonParameters>]


    DESCRIPTION
        The Export-AzRedisCache cmdlet exports data from Azure Cache for Redis to a specified container.


    PARAMETERS
        -Name <String>
            The name of the cache.

        -ResourceGroupName <String>
            The name of the resource group that contains the cache.

        -Prefix <String>
            Prefix to use for blob names.

        -Container <String>
            SAS url of container where data should be exported.

        -Format <String>
            Format for the blob.  Currently "rdb" is the only supported, with other formats expected in the future.

        -PassThru
            By default Export-AzRedisCache does not return any value. If the PassThru parameter is provided
            then Export-AzRedisCache returns a boolean value indicating the success of the operation.

        <CommonParameters>
            This cmdlet supports the common parameters: Verbose, Debug,
            ErrorAction, ErrorVariable, WarningAction, WarningVariable,
            OutBuffer, PipelineVariable, and OutVariable. For more information, see
            about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

Följande kommando exporterar data från en Azure Cache for Redis-instans till containern som anges av SAS-URI:n.

    PS C:\>Export-AzRedisCache -ResourceGroupName "resourceGroupName" -Name "cacheName" -Prefix "blobprefix"
    -Container "https://mystorageaccount.blob.core.windows.net/mycontainer?sv=2015-04-05&sr=c&sig=HezZtBZ3DURmEGDduauE7
    pvETY4kqlPI8JCNa8ATmaw%3D&st=2016-05-27T00%3A00%3A00Z&se=2016-05-28T00%3A00%3A00Z&sp=rwdl"

Starta om en Azure Cache for Redis

Du kan starta om Azure Cache for Redis-instansen med hjälp av cmdleten Reset-AzRedisCache .

Viktigt!

Omstart är endast tillgängligt för cacheminnen på Basic-, Standard- och Premium-nivå . Mer information om hur du startar om cacheminnet finns i Cacheadministration – omstart.

Om du vill se en lista över tillgängliga parametrar och deras beskrivningar för Reset-AzRedisCachekör du följande kommando.

    PS C:\> Get-Help Reset-AzRedisCache -detailed

    NAME
        Reset-AzRedisCache

    SYNOPSIS
        Reboot specified node(s) of an Azure Cache for Redis instance.


    SYNTAX
        Reset-AzRedisCache -Name <String> -ResourceGroupName <String> -RebootType <String> [-ShardId <Integer>]
        [-Force] [-PassThru] [<CommonParameters>]


    DESCRIPTION
        The Reset-AzRedisCache cmdlet reboots the specified node(s) of an Azure Cache for Redis instance.


    PARAMETERS
        -Name <String>
            The name of the cache.

        -ResourceGroupName <String>
            The name of the resource group that contains the cache.

        -RebootType <String>
            Which node to reboot. Possible values are "PrimaryNode", "SecondaryNode", "AllNodes".

        -ShardId <Integer>
            Which shard to reboot when rebooting a premium cache with clustering enabled.

        -Force
            When the Force parameter is provided, reset will be performed without any confirmation prompts.

        -PassThru
            By default Reset-AzRedisCache does not return any value. If the PassThru parameter is provided
            then Reset-AzRedisCache returns a boolean value indicating the success of the operation.

        <CommonParameters>
            This cmdlet supports the common parameters: Verbose, Debug,
            ErrorAction, ErrorVariable, WarningAction, WarningVariable,
            OutBuffer, PipelineVariable, and OutVariable. For more information, see
            about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).

Följande kommando startar om båda noderna i den angivna cachen.

    PS C:\>Reset-AzRedisCache -ResourceGroupName "resourceGroupName" -Name "cacheName" -RebootType "AllNodes"
    -Force

Nästa steg

Mer information om hur du använder Windows PowerShell med Azure finns i följande resurser: