Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}?api-version=2024-11-01
URI Parameters
Name |
In |
Required |
Type |
Description |
name
|
path |
True
|
string
|
The name of the Redis cache.
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
The name of the resource group. The name is case insensitive.
|
subscriptionId
|
path |
True
|
string
minLength: 1
|
The ID of the target subscription.
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
Request Body
Name |
Required |
Type |
Description |
location
|
True
|
string
|
The geo-location where the resource lives
|
properties.sku
|
True
|
Sku
|
The SKU of the Redis cache to deploy.
|
identity
|
|
ManagedServiceIdentity
|
The identity of the resource.
|
properties.disableAccessKeyAuthentication
|
|
boolean
|
Authentication to Redis through access keys is disabled when set as true. Default value is false.
|
properties.enableNonSslPort
|
|
boolean
|
Specifies whether the non-ssl Redis server port (6379) is enabled.
|
properties.minimumTlsVersion
|
|
TlsVersion
|
Optional: requires clients to use a specified TLS version (or higher) to connect (e,g, '1.0', '1.1', '1.2')
|
properties.publicNetworkAccess
|
|
PublicNetworkAccess
|
Whether or not public endpoint access is allowed for this cache. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'
|
properties.redisConfiguration
|
|
RedisConfiguration
|
All Redis Settings. Few possible keys: rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta, maxmemory-policy,notify-keyspace-events, aof-backup-enabled, aof-storage-connection-string-0, aof-storage-connection-string-1 etc.
|
properties.redisVersion
|
|
string
|
Redis version. This should be in the form 'major[.minor]' (only 'major' is required) or the value 'latest' which refers to the latest stable Redis version that is available. Supported versions: 4.0, 6.0 (latest). Default value is 'latest'.
|
properties.replicasPerMaster
|
|
integer
(int32)
|
The number of replicas to be created per primary.
|
properties.replicasPerPrimary
|
|
integer
(int32)
|
The number of replicas to be created per primary.
|
properties.shardCount
|
|
integer
(int32)
|
The number of shards to be created on a Premium Cluster Cache.
|
properties.staticIP
|
|
string
pattern: ^\d+\.\d+\.\d+\.\d+$
|
Static IP address. Optionally, may be specified when deploying a Redis cache inside an existing Azure Virtual Network; auto assigned by default.
|
properties.subnetId
|
|
string
pattern: ^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$
|
The full resource ID of a subnet in a virtual network to deploy the Redis cache in. Example format: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1
|
properties.tenantSettings
|
|
object
|
A dictionary of tenant settings
|
properties.updateChannel
|
|
UpdateChannel
|
Optional: Specifies the update channel for the monthly Redis updates your Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates at least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'.
|
properties.zonalAllocationPolicy
|
|
ZonalAllocationPolicy
|
Optional: Specifies how availability zones are allocated to the Redis cache. 'Automatic' enables zone redundancy and Azure will automatically select zones based on regional availability and capacity. 'UserDefined' will select availability zones passed in by you using the 'zones' parameter. 'NoZones' will produce a non-zonal cache. If 'zonalAllocationPolicy' is not passed, it will be set to 'UserDefined' when zones are passed in, otherwise, it will be set to 'Automatic' in regions where zones are supported and 'NoZones' in regions where zones are not supported.
|
tags
|
|
object
|
Resource tags.
|
zones
|
|
string[]
|
A list of availability zones denoting where the resource needs to come from.
|
Responses
Name |
Type |
Description |
200 OK
|
RedisResource
|
The existing redis cache was successfully updated. Check provisioningState to see detailed status.
|
201 Created
|
RedisResource
|
The new redis cache was successfully created. Check provisioningState to see detailed status.
|
Other Status Codes
|
ErrorResponse
|
Error response describing why the operation failed.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
impersonate your user account
|
Examples
RedisCacheCreate
Sample request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/redis/cache1?api-version=2024-11-01
{
"location": "East US",
"zones": [
"1"
],
"properties": {
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"redisVersion": "4",
"enableNonSslPort": true,
"shardCount": 2,
"replicasPerPrimary": 2,
"redisConfiguration": {
"maxmemory-policy": "allkeys-lru"
},
"subnetId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
"staticIP": "192.168.0.5",
"minimumTlsVersion": "1.2"
}
}
import com.azure.resourcemanager.redis.models.RedisConfiguration;
import com.azure.resourcemanager.redis.models.RedisCreateParameters;
import com.azure.resourcemanager.redis.models.Sku;
import com.azure.resourcemanager.redis.models.SkuFamily;
import com.azure.resourcemanager.redis.models.SkuName;
import com.azure.resourcemanager.redis.models.TlsVersion;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Redis Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreate.json
*/
/**
* Sample code: RedisCacheCreate.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void redisCacheCreate(com.azure.resourcemanager.AzureResourceManager azure) {
azure.redisCaches().manager().serviceClient().getRedis().create("rg1", "cache1", new RedisCreateParameters()
.withZones(Arrays.asList("1")).withLocation("East US")
.withSku(new Sku().withName(SkuName.PREMIUM).withFamily(SkuFamily.P).withCapacity(1))
.withSubnetId(
"/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1")
.withStaticIp("192.168.0.5")
.withRedisConfiguration(
new RedisConfiguration().withMaxmemoryPolicy("allkeys-lru").withAdditionalProperties(mapOf()))
.withRedisVersion("4").withEnableNonSslPort(true).withReplicasPerPrimary(2).withShardCount(2)
.withMinimumTlsVersion(TlsVersion.ONE_TWO), com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.redis import RedisManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-redis
# USAGE
python redis_cache_create.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = RedisManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.redis.begin_create(
resource_group_name="rg1",
name="cache1",
parameters={
"location": "East US",
"properties": {
"enableNonSslPort": True,
"minimumTlsVersion": "1.2",
"redisConfiguration": {"maxmemory-policy": "allkeys-lru"},
"redisVersion": "4",
"replicasPerPrimary": 2,
"shardCount": 2,
"sku": {"capacity": 1, "family": "P", "name": "Premium"},
"staticIP": "192.168.0.5",
"subnetId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
},
"zones": ["1"],
},
).result()
print(response)
# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreate.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armredis_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redis/armredis/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/45374f48f560b3337ed55735038f1e9bf8cbea65/specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreate.json
func ExampleClient_BeginCreate_redisCacheCreate() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armredis.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClient().BeginCreate(ctx, "rg1", "cache1", armredis.CreateParameters{
Location: to.Ptr("East US"),
Properties: &armredis.CreateProperties{
EnableNonSSLPort: to.Ptr(true),
MinimumTLSVersion: to.Ptr(armredis.TLSVersionOne2),
RedisConfiguration: &armredis.CommonPropertiesRedisConfiguration{
MaxmemoryPolicy: to.Ptr("allkeys-lru"),
},
RedisVersion: to.Ptr("4"),
ReplicasPerPrimary: to.Ptr[int32](2),
ShardCount: to.Ptr[int32](2),
SKU: &armredis.SKU{
Name: to.Ptr(armredis.SKUNamePremium),
Capacity: to.Ptr[int32](1),
Family: to.Ptr(armredis.SKUFamilyP),
},
StaticIP: to.Ptr("192.168.0.5"),
SubnetID: to.Ptr("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1"),
},
Zones: []*string{
to.Ptr("1")},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ResourceInfo = armredis.ResourceInfo{
// Name: to.Ptr("cache1"),
// Type: to.Ptr("Microsoft.Cache/Redis"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1"),
// Location: to.Ptr("West US"),
// Tags: map[string]*string{
// },
// Properties: &armredis.Properties{
// EnableNonSSLPort: to.Ptr(false),
// MinimumTLSVersion: to.Ptr(armredis.TLSVersionOne2),
// RedisConfiguration: &armredis.CommonPropertiesRedisConfiguration{
// Maxclients: to.Ptr("1000"),
// MaxmemoryDelta: to.Ptr("50"),
// MaxmemoryReserved: to.Ptr("50"),
// },
// RedisVersion: to.Ptr("4.0.14"),
// ReplicasPerMaster: to.Ptr[int32](2),
// ReplicasPerPrimary: to.Ptr[int32](2),
// UpdateChannel: to.Ptr(armredis.UpdateChannelStable),
// ZonalAllocationPolicy: to.Ptr(armredis.ZonalAllocationPolicyUserDefined),
// SKU: &armredis.SKU{
// Name: to.Ptr(armredis.SKUNamePremium),
// Capacity: to.Ptr[int32](1),
// Family: to.Ptr(armredis.SKUFamilyP),
// },
// AccessKeys: &armredis.AccessKeys{
// PrimaryKey: to.Ptr("<primaryKey>"),
// SecondaryKey: to.Ptr("<secondaryKey>"),
// },
// HostName: to.Ptr("cache1.redis.cache.windows.net"),
// Instances: []*armredis.InstanceDetails{
// {
// IsMaster: to.Ptr(true),
// IsPrimary: to.Ptr(true),
// NonSSLPort: to.Ptr[int32](13000),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15000),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13001),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15001),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13002),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15002),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(true),
// IsPrimary: to.Ptr(true),
// NonSSLPort: to.Ptr[int32](13003),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15003),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13004),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15004),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13005),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15005),
// Zone: to.Ptr("1"),
// }},
// Port: to.Ptr[int32](6379),
// ProvisioningState: to.Ptr(armredis.ProvisioningStateSucceeded),
// SSLPort: to.Ptr[int32](6380),
// },
// Zones: []*string{
// to.Ptr("1")},
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RedisManagementClient } = require("@azure/arm-rediscache");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
*
* @summary Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
* x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreate.json
*/
async function redisCacheCreate() {
const subscriptionId = process.env["REDIS_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["REDIS_RESOURCE_GROUP"] || "rg1";
const name = "cache1";
const parameters = {
enableNonSslPort: true,
location: "East US",
minimumTlsVersion: "1.2",
redisConfiguration: { maxmemoryPolicy: "allkeys-lru" },
redisVersion: "4",
replicasPerPrimary: 2,
shardCount: 2,
sku: { name: "Premium", capacity: 1, family: "P" },
staticIP: "192.168.0.5",
subnetId:
"/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
zones: ["1"],
};
const credential = new DefaultAzureCredential();
const client = new RedisManagementClient(credential, subscriptionId);
const result = await client.redis.beginCreateAndWait(resourceGroupName, name, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Net;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Redis.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Redis;
// Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreate.json
// this example is just showing the usage of "Redis_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this RedisResource
RedisCollection collection = resourceGroupResource.GetAllRedis();
// invoke the operation
string name = "cache1";
RedisCreateOrUpdateContent content = new RedisCreateOrUpdateContent(new AzureLocation("East US"), new RedisSku(RedisSkuName.Premium, RedisSkuFamily.Premium, 1))
{
Zones = { "1" },
RedisConfiguration = new RedisCommonConfiguration
{
MaxMemoryPolicy = "allkeys-lru",
},
RedisVersion = "4",
EnableNonSslPort = true,
ReplicasPerPrimary = 2,
ShardCount = 2,
MinimumTlsVersion = RedisTlsVersion.Tls1_2,
SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1"),
StaticIP = IPAddress.Parse("192.168.0.5"),
};
ArmOperation<RedisResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, content);
RedisResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
RedisData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1",
"location": "West US",
"zones": [
"1"
],
"name": "cache1",
"type": "Microsoft.Cache/Redis",
"tags": {},
"properties": {
"accessKeys": {
"primaryKey": "<primaryKey>",
"secondaryKey": "<secondaryKey>"
},
"provisioningState": "Succeeded",
"redisVersion": "4.0.14",
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"enableNonSslPort": false,
"replicasPerMaster": 2,
"replicasPerPrimary": 2,
"updateChannel": "Stable",
"zonalAllocationPolicy": "UserDefined",
"redisConfiguration": {
"maxmemory-policy": "allkeys-lru"
},
"hostName": "cache1.redis.cache.windows.net",
"port": 6379,
"sslPort": 6380,
"minimumTlsVersion": "1.2",
"instances": [
{
"sslPort": 15000,
"nonSslPort": 13000,
"zone": "1",
"shardId": 0,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15001,
"nonSslPort": 13001,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15002,
"nonSslPort": 13002,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15003,
"nonSslPort": 13003,
"zone": "1",
"shardId": 1,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15004,
"nonSslPort": 13004,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15005,
"nonSslPort": 13005,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
}
]
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1",
"location": "West US",
"zones": [
"1"
],
"name": "cache1",
"type": "Microsoft.Cache/Redis",
"tags": {},
"properties": {
"accessKeys": {
"primaryKey": "<primaryKey>",
"secondaryKey": "<secondaryKey>"
},
"provisioningState": "Succeeded",
"redisVersion": "4.0.14",
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"enableNonSslPort": false,
"replicasPerMaster": 2,
"replicasPerPrimary": 2,
"updateChannel": "Stable",
"zonalAllocationPolicy": "UserDefined",
"redisConfiguration": {
"maxclients": "1000",
"maxmemory-reserved": "50",
"maxmemory-delta": "50"
},
"hostName": "cache1.redis.cache.windows.net",
"port": 6379,
"sslPort": 6380,
"minimumTlsVersion": "1.2",
"instances": [
{
"sslPort": 15000,
"nonSslPort": 13000,
"zone": "1",
"shardId": 0,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15001,
"nonSslPort": 13001,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15002,
"nonSslPort": 13002,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15003,
"nonSslPort": 13003,
"zone": "1",
"shardId": 1,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15004,
"nonSslPort": 13004,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15005,
"nonSslPort": 13005,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
}
]
}
}
RedisCacheCreateAutomaticZonalAllocationPolicy
Sample request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/redis/cache1?api-version=2024-11-01
{
"location": "East US",
"properties": {
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"enableNonSslPort": true,
"shardCount": 2,
"replicasPerPrimary": 2,
"zonalAllocationPolicy": "Automatic",
"redisConfiguration": {
"maxmemory-policy": "allkeys-lru"
},
"subnetId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
"staticIP": "192.168.0.5",
"minimumTlsVersion": "1.2"
}
}
import com.azure.resourcemanager.redis.models.RedisConfiguration;
import com.azure.resourcemanager.redis.models.RedisCreateParameters;
import com.azure.resourcemanager.redis.models.Sku;
import com.azure.resourcemanager.redis.models.SkuFamily;
import com.azure.resourcemanager.redis.models.SkuName;
import com.azure.resourcemanager.redis.models.TlsVersion;
import com.azure.resourcemanager.redis.models.ZonalAllocationPolicy;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Redis Create.
*/
public final class Main {
/*
* x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/
* RedisCacheCreateAutomaticZonalAllocationPolicy.json
*/
/**
* Sample code: RedisCacheCreateAutomaticZonalAllocationPolicy.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
redisCacheCreateAutomaticZonalAllocationPolicy(com.azure.resourcemanager.AzureResourceManager azure) {
azure.redisCaches().manager().serviceClient().getRedis().create("rg1", "cache1", new RedisCreateParameters()
.withLocation("East US")
.withSku(new Sku().withName(SkuName.PREMIUM).withFamily(SkuFamily.P).withCapacity(1))
.withSubnetId(
"/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1")
.withStaticIp("192.168.0.5")
.withRedisConfiguration(
new RedisConfiguration().withMaxmemoryPolicy("allkeys-lru").withAdditionalProperties(mapOf()))
.withEnableNonSslPort(true).withReplicasPerPrimary(2).withShardCount(2)
.withMinimumTlsVersion(TlsVersion.ONE_TWO).withZonalAllocationPolicy(ZonalAllocationPolicy.AUTOMATIC),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.redis import RedisManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-redis
# USAGE
python redis_cache_create_automatic_zonal_allocation_policy.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = RedisManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.redis.begin_create(
resource_group_name="rg1",
name="cache1",
parameters={
"location": "East US",
"properties": {
"enableNonSslPort": True,
"minimumTlsVersion": "1.2",
"redisConfiguration": {"maxmemory-policy": "allkeys-lru"},
"replicasPerPrimary": 2,
"shardCount": 2,
"sku": {"capacity": 1, "family": "P", "name": "Premium"},
"staticIP": "192.168.0.5",
"subnetId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
"zonalAllocationPolicy": "Automatic",
},
},
).result()
print(response)
# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateAutomaticZonalAllocationPolicy.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armredis_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redis/armredis/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/45374f48f560b3337ed55735038f1e9bf8cbea65/specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateAutomaticZonalAllocationPolicy.json
func ExampleClient_BeginCreate_redisCacheCreateAutomaticZonalAllocationPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armredis.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClient().BeginCreate(ctx, "rg1", "cache1", armredis.CreateParameters{
Location: to.Ptr("East US"),
Properties: &armredis.CreateProperties{
EnableNonSSLPort: to.Ptr(true),
MinimumTLSVersion: to.Ptr(armredis.TLSVersionOne2),
RedisConfiguration: &armredis.CommonPropertiesRedisConfiguration{
MaxmemoryPolicy: to.Ptr("allkeys-lru"),
},
ReplicasPerPrimary: to.Ptr[int32](2),
ShardCount: to.Ptr[int32](2),
ZonalAllocationPolicy: to.Ptr(armredis.ZonalAllocationPolicyAutomatic),
SKU: &armredis.SKU{
Name: to.Ptr(armredis.SKUNamePremium),
Capacity: to.Ptr[int32](1),
Family: to.Ptr(armredis.SKUFamilyP),
},
StaticIP: to.Ptr("192.168.0.5"),
SubnetID: to.Ptr("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ResourceInfo = armredis.ResourceInfo{
// Name: to.Ptr("cache1"),
// Type: to.Ptr("Microsoft.Cache/Redis"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1"),
// Location: to.Ptr("East US"),
// Tags: map[string]*string{
// },
// Properties: &armredis.Properties{
// EnableNonSSLPort: to.Ptr(true),
// MinimumTLSVersion: to.Ptr(armredis.TLSVersionOne2),
// RedisConfiguration: &armredis.CommonPropertiesRedisConfiguration{
// Maxclients: to.Ptr("1000"),
// MaxmemoryDelta: to.Ptr("50"),
// MaxmemoryReserved: to.Ptr("50"),
// },
// RedisVersion: to.Ptr("6.0"),
// ReplicasPerMaster: to.Ptr[int32](2),
// ReplicasPerPrimary: to.Ptr[int32](2),
// ShardCount: to.Ptr[int32](2),
// UpdateChannel: to.Ptr(armredis.UpdateChannelStable),
// ZonalAllocationPolicy: to.Ptr(armredis.ZonalAllocationPolicyAutomatic),
// SKU: &armredis.SKU{
// Name: to.Ptr(armredis.SKUNamePremium),
// Capacity: to.Ptr[int32](1),
// Family: to.Ptr(armredis.SKUFamilyP),
// },
// AccessKeys: &armredis.AccessKeys{
// PrimaryKey: to.Ptr("<primaryKey>"),
// SecondaryKey: to.Ptr("<secondaryKey>"),
// },
// HostName: to.Ptr("cache1.redis.cache.windows.net"),
// Instances: []*armredis.InstanceDetails{
// {
// IsMaster: to.Ptr(true),
// IsPrimary: to.Ptr(true),
// NonSSLPort: to.Ptr[int32](13000),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15000),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13001),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15001),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13002),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15002),
// },
// {
// IsMaster: to.Ptr(true),
// IsPrimary: to.Ptr(true),
// NonSSLPort: to.Ptr[int32](13003),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15003),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13004),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15004),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13005),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15005),
// }},
// Port: to.Ptr[int32](6379),
// ProvisioningState: to.Ptr(armredis.ProvisioningStateSucceeded),
// SSLPort: to.Ptr[int32](6380),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RedisManagementClient } = require("@azure/arm-rediscache");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
*
* @summary Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
* x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateAutomaticZonalAllocationPolicy.json
*/
async function redisCacheCreateAutomaticZonalAllocationPolicy() {
const subscriptionId = process.env["REDIS_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["REDIS_RESOURCE_GROUP"] || "rg1";
const name = "cache1";
const parameters = {
enableNonSslPort: true,
location: "East US",
minimumTlsVersion: "1.2",
redisConfiguration: { maxmemoryPolicy: "allkeys-lru" },
replicasPerPrimary: 2,
shardCount: 2,
sku: { name: "Premium", capacity: 1, family: "P" },
staticIP: "192.168.0.5",
subnetId:
"/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
zonalAllocationPolicy: "Automatic",
};
const credential = new DefaultAzureCredential();
const client = new RedisManagementClient(credential, subscriptionId);
const result = await client.redis.beginCreateAndWait(resourceGroupName, name, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Net;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Redis.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Redis;
// Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateAutomaticZonalAllocationPolicy.json
// this example is just showing the usage of "Redis_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this RedisResource
RedisCollection collection = resourceGroupResource.GetAllRedis();
// invoke the operation
string name = "cache1";
RedisCreateOrUpdateContent content = new RedisCreateOrUpdateContent(new AzureLocation("East US"), new RedisSku(RedisSkuName.Premium, RedisSkuFamily.Premium, 1))
{
RedisConfiguration = new RedisCommonConfiguration
{
MaxMemoryPolicy = "allkeys-lru",
},
EnableNonSslPort = true,
ReplicasPerPrimary = 2,
ShardCount = 2,
MinimumTlsVersion = RedisTlsVersion.Tls1_2,
ZonalAllocationPolicy = ZonalAllocationPolicy.Automatic,
SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1"),
StaticIP = IPAddress.Parse("192.168.0.5"),
};
ArmOperation<RedisResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, content);
RedisResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
RedisData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1",
"location": "East US",
"name": "cache1",
"type": "Microsoft.Cache/Redis",
"tags": {},
"properties": {
"accessKeys": {
"primaryKey": "<primaryKey>",
"secondaryKey": "<secondaryKey>"
},
"provisioningState": "Succeeded",
"redisVersion": "6.0",
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"shardCount": 2,
"enableNonSslPort": true,
"replicasPerMaster": 2,
"replicasPerPrimary": 2,
"updateChannel": "Stable",
"zonalAllocationPolicy": "Automatic",
"redisConfiguration": {
"maxmemory-policy": "allkeys-lru"
},
"hostName": "cache1.redis.cache.windows.net",
"port": 6379,
"sslPort": 6380,
"minimumTlsVersion": "1.2",
"instances": [
{
"sslPort": 15000,
"nonSslPort": 13000,
"shardId": 0,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15001,
"nonSslPort": 13001,
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15002,
"nonSslPort": 13002,
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15003,
"nonSslPort": 13003,
"shardId": 1,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15004,
"nonSslPort": 13004,
"shardId": 1,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15005,
"nonSslPort": 13005,
"shardId": 1,
"isMaster": false,
"isPrimary": false
}
]
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1",
"location": "East US",
"name": "cache1",
"type": "Microsoft.Cache/Redis",
"tags": {},
"properties": {
"accessKeys": {
"primaryKey": "<primaryKey>",
"secondaryKey": "<secondaryKey>"
},
"provisioningState": "Succeeded",
"redisVersion": "6.0",
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"shardCount": 2,
"enableNonSslPort": true,
"replicasPerMaster": 2,
"replicasPerPrimary": 2,
"updateChannel": "Stable",
"zonalAllocationPolicy": "Automatic",
"redisConfiguration": {
"maxclients": "1000",
"maxmemory-reserved": "50",
"maxmemory-delta": "50"
},
"hostName": "cache1.redis.cache.windows.net",
"port": 6379,
"sslPort": 6380,
"minimumTlsVersion": "1.2",
"instances": [
{
"sslPort": 15000,
"nonSslPort": 13000,
"shardId": 0,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15001,
"nonSslPort": 13001,
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15002,
"nonSslPort": 13002,
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15003,
"nonSslPort": 13003,
"shardId": 1,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15004,
"nonSslPort": 13004,
"shardId": 1,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15005,
"nonSslPort": 13005,
"shardId": 1,
"isMaster": false,
"isPrimary": false
}
]
}
}
RedisCacheCreateDefaultVersion
Sample request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/redis/cache1?api-version=2024-11-01
{
"location": "East US",
"zones": [
"1"
],
"properties": {
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"enableNonSslPort": true,
"shardCount": 2,
"replicasPerPrimary": 2,
"redisConfiguration": {
"maxmemory-policy": "allkeys-lru"
},
"subnetId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
"staticIP": "192.168.0.5",
"minimumTlsVersion": "1.2"
}
}
import com.azure.resourcemanager.redis.models.RedisConfiguration;
import com.azure.resourcemanager.redis.models.RedisCreateParameters;
import com.azure.resourcemanager.redis.models.Sku;
import com.azure.resourcemanager.redis.models.SkuFamily;
import com.azure.resourcemanager.redis.models.SkuName;
import com.azure.resourcemanager.redis.models.TlsVersion;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Redis Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateDefaultVersion.
* json
*/
/**
* Sample code: RedisCacheCreateDefaultVersion.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void redisCacheCreateDefaultVersion(com.azure.resourcemanager.AzureResourceManager azure) {
azure.redisCaches().manager().serviceClient().getRedis().create("rg1", "cache1", new RedisCreateParameters()
.withZones(Arrays.asList("1")).withLocation("East US")
.withSku(new Sku().withName(SkuName.PREMIUM).withFamily(SkuFamily.P).withCapacity(1))
.withSubnetId(
"/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1")
.withStaticIp("192.168.0.5")
.withRedisConfiguration(
new RedisConfiguration().withMaxmemoryPolicy("allkeys-lru").withAdditionalProperties(mapOf()))
.withEnableNonSslPort(true).withReplicasPerPrimary(2).withShardCount(2)
.withMinimumTlsVersion(TlsVersion.ONE_TWO), com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.redis import RedisManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-redis
# USAGE
python redis_cache_create_default_version.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = RedisManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.redis.begin_create(
resource_group_name="rg1",
name="cache1",
parameters={
"location": "East US",
"properties": {
"enableNonSslPort": True,
"minimumTlsVersion": "1.2",
"redisConfiguration": {"maxmemory-policy": "allkeys-lru"},
"replicasPerPrimary": 2,
"shardCount": 2,
"sku": {"capacity": 1, "family": "P", "name": "Premium"},
"staticIP": "192.168.0.5",
"subnetId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
},
"zones": ["1"],
},
).result()
print(response)
# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateDefaultVersion.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armredis_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redis/armredis/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/45374f48f560b3337ed55735038f1e9bf8cbea65/specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateDefaultVersion.json
func ExampleClient_BeginCreate_redisCacheCreateDefaultVersion() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armredis.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClient().BeginCreate(ctx, "rg1", "cache1", armredis.CreateParameters{
Location: to.Ptr("East US"),
Properties: &armredis.CreateProperties{
EnableNonSSLPort: to.Ptr(true),
MinimumTLSVersion: to.Ptr(armredis.TLSVersionOne2),
RedisConfiguration: &armredis.CommonPropertiesRedisConfiguration{
MaxmemoryPolicy: to.Ptr("allkeys-lru"),
},
ReplicasPerPrimary: to.Ptr[int32](2),
ShardCount: to.Ptr[int32](2),
SKU: &armredis.SKU{
Name: to.Ptr(armredis.SKUNamePremium),
Capacity: to.Ptr[int32](1),
Family: to.Ptr(armredis.SKUFamilyP),
},
StaticIP: to.Ptr("192.168.0.5"),
SubnetID: to.Ptr("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1"),
},
Zones: []*string{
to.Ptr("1")},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ResourceInfo = armredis.ResourceInfo{
// Name: to.Ptr("cache1"),
// Type: to.Ptr("Microsoft.Cache/Redis"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1"),
// Location: to.Ptr("West US"),
// Tags: map[string]*string{
// },
// Properties: &armredis.Properties{
// EnableNonSSLPort: to.Ptr(false),
// MinimumTLSVersion: to.Ptr(armredis.TLSVersionOne2),
// RedisConfiguration: &armredis.CommonPropertiesRedisConfiguration{
// Maxclients: to.Ptr("1000"),
// MaxmemoryDelta: to.Ptr("50"),
// MaxmemoryReserved: to.Ptr("50"),
// },
// RedisVersion: to.Ptr("6.0.14"),
// ReplicasPerMaster: to.Ptr[int32](2),
// ReplicasPerPrimary: to.Ptr[int32](2),
// UpdateChannel: to.Ptr(armredis.UpdateChannelStable),
// ZonalAllocationPolicy: to.Ptr(armredis.ZonalAllocationPolicyUserDefined),
// SKU: &armredis.SKU{
// Name: to.Ptr(armredis.SKUNamePremium),
// Capacity: to.Ptr[int32](1),
// Family: to.Ptr(armredis.SKUFamilyP),
// },
// AccessKeys: &armredis.AccessKeys{
// PrimaryKey: to.Ptr("<primaryKey>"),
// SecondaryKey: to.Ptr("<secondaryKey>"),
// },
// HostName: to.Ptr("cache1.redis.cache.windows.net"),
// Instances: []*armredis.InstanceDetails{
// {
// IsMaster: to.Ptr(true),
// IsPrimary: to.Ptr(true),
// NonSSLPort: to.Ptr[int32](13000),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15000),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13001),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15001),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13002),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15002),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(true),
// IsPrimary: to.Ptr(true),
// NonSSLPort: to.Ptr[int32](13003),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15003),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13004),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15004),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13005),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15005),
// Zone: to.Ptr("1"),
// }},
// Port: to.Ptr[int32](6379),
// ProvisioningState: to.Ptr(armredis.ProvisioningStateSucceeded),
// SSLPort: to.Ptr[int32](6380),
// },
// Zones: []*string{
// to.Ptr("1")},
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RedisManagementClient } = require("@azure/arm-rediscache");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
*
* @summary Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
* x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateDefaultVersion.json
*/
async function redisCacheCreateDefaultVersion() {
const subscriptionId = process.env["REDIS_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["REDIS_RESOURCE_GROUP"] || "rg1";
const name = "cache1";
const parameters = {
enableNonSslPort: true,
location: "East US",
minimumTlsVersion: "1.2",
redisConfiguration: { maxmemoryPolicy: "allkeys-lru" },
replicasPerPrimary: 2,
shardCount: 2,
sku: { name: "Premium", capacity: 1, family: "P" },
staticIP: "192.168.0.5",
subnetId:
"/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
zones: ["1"],
};
const credential = new DefaultAzureCredential();
const client = new RedisManagementClient(credential, subscriptionId);
const result = await client.redis.beginCreateAndWait(resourceGroupName, name, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Net;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Redis.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Redis;
// Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateDefaultVersion.json
// this example is just showing the usage of "Redis_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this RedisResource
RedisCollection collection = resourceGroupResource.GetAllRedis();
// invoke the operation
string name = "cache1";
RedisCreateOrUpdateContent content = new RedisCreateOrUpdateContent(new AzureLocation("East US"), new RedisSku(RedisSkuName.Premium, RedisSkuFamily.Premium, 1))
{
Zones = { "1" },
RedisConfiguration = new RedisCommonConfiguration
{
MaxMemoryPolicy = "allkeys-lru",
},
EnableNonSslPort = true,
ReplicasPerPrimary = 2,
ShardCount = 2,
MinimumTlsVersion = RedisTlsVersion.Tls1_2,
SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1"),
StaticIP = IPAddress.Parse("192.168.0.5"),
};
ArmOperation<RedisResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, content);
RedisResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
RedisData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1",
"location": "West US",
"zones": [
"1"
],
"name": "cache1",
"type": "Microsoft.Cache/Redis",
"tags": {},
"properties": {
"accessKeys": {
"primaryKey": "<primaryKey>",
"secondaryKey": "<secondaryKey>"
},
"provisioningState": "Succeeded",
"redisVersion": "6.0.14",
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"enableNonSslPort": false,
"replicasPerMaster": 2,
"replicasPerPrimary": 2,
"updateChannel": "Stable",
"zonalAllocationPolicy": "UserDefined",
"redisConfiguration": {
"maxmemory-policy": "allkeys-lru"
},
"hostName": "cache1.redis.cache.windows.net",
"port": 6379,
"sslPort": 6380,
"minimumTlsVersion": "1.2",
"instances": [
{
"sslPort": 15000,
"nonSslPort": 13000,
"zone": "1",
"shardId": 0,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15001,
"nonSslPort": 13001,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15002,
"nonSslPort": 13002,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15003,
"nonSslPort": 13003,
"zone": "1",
"shardId": 1,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15004,
"nonSslPort": 13004,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15005,
"nonSslPort": 13005,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
}
]
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1",
"location": "West US",
"zones": [
"1"
],
"name": "cache1",
"type": "Microsoft.Cache/Redis",
"tags": {},
"properties": {
"accessKeys": {
"primaryKey": "<primaryKey>",
"secondaryKey": "<secondaryKey>"
},
"provisioningState": "Succeeded",
"redisVersion": "6.0.14",
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"enableNonSslPort": false,
"replicasPerMaster": 2,
"replicasPerPrimary": 2,
"updateChannel": "Stable",
"zonalAllocationPolicy": "UserDefined",
"redisConfiguration": {
"maxclients": "1000",
"maxmemory-reserved": "50",
"maxmemory-delta": "50"
},
"hostName": "cache1.redis.cache.windows.net",
"port": 6379,
"sslPort": 6380,
"minimumTlsVersion": "1.2",
"instances": [
{
"sslPort": 15000,
"nonSslPort": 13000,
"zone": "1",
"shardId": 0,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15001,
"nonSslPort": 13001,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15002,
"nonSslPort": 13002,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15003,
"nonSslPort": 13003,
"zone": "1",
"shardId": 1,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15004,
"nonSslPort": 13004,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15005,
"nonSslPort": 13005,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
}
]
}
}
RedisCacheCreateLatestVersion
Sample request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/redis/cache1?api-version=2024-11-01
{
"location": "East US",
"zones": [
"1"
],
"properties": {
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"redisVersion": "Latest",
"enableNonSslPort": true,
"shardCount": 2,
"replicasPerPrimary": 2,
"redisConfiguration": {
"maxmemory-policy": "allkeys-lru"
},
"subnetId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
"staticIP": "192.168.0.5",
"minimumTlsVersion": "1.2"
}
}
import com.azure.resourcemanager.redis.models.RedisConfiguration;
import com.azure.resourcemanager.redis.models.RedisCreateParameters;
import com.azure.resourcemanager.redis.models.Sku;
import com.azure.resourcemanager.redis.models.SkuFamily;
import com.azure.resourcemanager.redis.models.SkuName;
import com.azure.resourcemanager.redis.models.TlsVersion;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Redis Create.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateLatestVersion.
* json
*/
/**
* Sample code: RedisCacheCreateLatestVersion.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void redisCacheCreateLatestVersion(com.azure.resourcemanager.AzureResourceManager azure) {
azure.redisCaches().manager().serviceClient().getRedis().create("rg1", "cache1", new RedisCreateParameters()
.withZones(Arrays.asList("1")).withLocation("East US")
.withSku(new Sku().withName(SkuName.PREMIUM).withFamily(SkuFamily.P).withCapacity(1))
.withSubnetId(
"/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1")
.withStaticIp("192.168.0.5")
.withRedisConfiguration(
new RedisConfiguration().withMaxmemoryPolicy("allkeys-lru").withAdditionalProperties(mapOf()))
.withRedisVersion("Latest").withEnableNonSslPort(true).withReplicasPerPrimary(2).withShardCount(2)
.withMinimumTlsVersion(TlsVersion.ONE_TWO), com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.redis import RedisManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-redis
# USAGE
python redis_cache_create_latest_version.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = RedisManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.redis.begin_create(
resource_group_name="rg1",
name="cache1",
parameters={
"location": "East US",
"properties": {
"enableNonSslPort": True,
"minimumTlsVersion": "1.2",
"redisConfiguration": {"maxmemory-policy": "allkeys-lru"},
"redisVersion": "Latest",
"replicasPerPrimary": 2,
"shardCount": 2,
"sku": {"capacity": 1, "family": "P", "name": "Premium"},
"staticIP": "192.168.0.5",
"subnetId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
},
"zones": ["1"],
},
).result()
print(response)
# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateLatestVersion.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armredis_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redis/armredis/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/45374f48f560b3337ed55735038f1e9bf8cbea65/specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateLatestVersion.json
func ExampleClient_BeginCreate_redisCacheCreateLatestVersion() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armredis.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClient().BeginCreate(ctx, "rg1", "cache1", armredis.CreateParameters{
Location: to.Ptr("East US"),
Properties: &armredis.CreateProperties{
EnableNonSSLPort: to.Ptr(true),
MinimumTLSVersion: to.Ptr(armredis.TLSVersionOne2),
RedisConfiguration: &armredis.CommonPropertiesRedisConfiguration{
MaxmemoryPolicy: to.Ptr("allkeys-lru"),
},
RedisVersion: to.Ptr("Latest"),
ReplicasPerPrimary: to.Ptr[int32](2),
ShardCount: to.Ptr[int32](2),
SKU: &armredis.SKU{
Name: to.Ptr(armredis.SKUNamePremium),
Capacity: to.Ptr[int32](1),
Family: to.Ptr(armredis.SKUFamilyP),
},
StaticIP: to.Ptr("192.168.0.5"),
SubnetID: to.Ptr("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1"),
},
Zones: []*string{
to.Ptr("1")},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ResourceInfo = armredis.ResourceInfo{
// Name: to.Ptr("cache1"),
// Type: to.Ptr("Microsoft.Cache/Redis"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1"),
// Location: to.Ptr("West US"),
// Tags: map[string]*string{
// },
// Properties: &armredis.Properties{
// EnableNonSSLPort: to.Ptr(false),
// MinimumTLSVersion: to.Ptr(armredis.TLSVersionOne2),
// RedisConfiguration: &armredis.CommonPropertiesRedisConfiguration{
// Maxclients: to.Ptr("1000"),
// MaxmemoryDelta: to.Ptr("50"),
// MaxmemoryReserved: to.Ptr("50"),
// },
// RedisVersion: to.Ptr("6.0.14"),
// ReplicasPerMaster: to.Ptr[int32](2),
// ReplicasPerPrimary: to.Ptr[int32](2),
// UpdateChannel: to.Ptr(armredis.UpdateChannelStable),
// ZonalAllocationPolicy: to.Ptr(armredis.ZonalAllocationPolicyUserDefined),
// SKU: &armredis.SKU{
// Name: to.Ptr(armredis.SKUNamePremium),
// Capacity: to.Ptr[int32](1),
// Family: to.Ptr(armredis.SKUFamilyP),
// },
// AccessKeys: &armredis.AccessKeys{
// PrimaryKey: to.Ptr("<primaryKey>"),
// SecondaryKey: to.Ptr("<secondaryKey>"),
// },
// HostName: to.Ptr("cache1.redis.cache.windows.net"),
// Instances: []*armredis.InstanceDetails{
// {
// IsMaster: to.Ptr(true),
// IsPrimary: to.Ptr(true),
// NonSSLPort: to.Ptr[int32](13000),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15000),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13001),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15001),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13002),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15002),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(true),
// IsPrimary: to.Ptr(true),
// NonSSLPort: to.Ptr[int32](13003),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15003),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13004),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15004),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13005),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15005),
// Zone: to.Ptr("1"),
// }},
// Port: to.Ptr[int32](6379),
// ProvisioningState: to.Ptr(armredis.ProvisioningStateSucceeded),
// SSLPort: to.Ptr[int32](6380),
// },
// Zones: []*string{
// to.Ptr("1")},
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RedisManagementClient } = require("@azure/arm-rediscache");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
*
* @summary Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
* x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateLatestVersion.json
*/
async function redisCacheCreateLatestVersion() {
const subscriptionId = process.env["REDIS_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["REDIS_RESOURCE_GROUP"] || "rg1";
const name = "cache1";
const parameters = {
enableNonSslPort: true,
location: "East US",
minimumTlsVersion: "1.2",
redisConfiguration: { maxmemoryPolicy: "allkeys-lru" },
redisVersion: "Latest",
replicasPerPrimary: 2,
shardCount: 2,
sku: { name: "Premium", capacity: 1, family: "P" },
staticIP: "192.168.0.5",
subnetId:
"/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
zones: ["1"],
};
const credential = new DefaultAzureCredential();
const client = new RedisManagementClient(credential, subscriptionId);
const result = await client.redis.beginCreateAndWait(resourceGroupName, name, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Net;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Redis.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Redis;
// Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateLatestVersion.json
// this example is just showing the usage of "Redis_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this RedisResource
RedisCollection collection = resourceGroupResource.GetAllRedis();
// invoke the operation
string name = "cache1";
RedisCreateOrUpdateContent content = new RedisCreateOrUpdateContent(new AzureLocation("East US"), new RedisSku(RedisSkuName.Premium, RedisSkuFamily.Premium, 1))
{
Zones = { "1" },
RedisConfiguration = new RedisCommonConfiguration
{
MaxMemoryPolicy = "allkeys-lru",
},
RedisVersion = "Latest",
EnableNonSslPort = true,
ReplicasPerPrimary = 2,
ShardCount = 2,
MinimumTlsVersion = RedisTlsVersion.Tls1_2,
SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1"),
StaticIP = IPAddress.Parse("192.168.0.5"),
};
ArmOperation<RedisResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, content);
RedisResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
RedisData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1",
"location": "West US",
"zones": [
"1"
],
"name": "cache1",
"type": "Microsoft.Cache/Redis",
"tags": {},
"properties": {
"accessKeys": {
"primaryKey": "<primaryKey>",
"secondaryKey": "<secondaryKey>"
},
"provisioningState": "Succeeded",
"redisVersion": "6.0.14",
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"enableNonSslPort": false,
"replicasPerMaster": 2,
"replicasPerPrimary": 2,
"updateChannel": "Stable",
"zonalAllocationPolicy": "UserDefined",
"redisConfiguration": {
"maxmemory-policy": "allkeys-lru"
},
"hostName": "cache1.redis.cache.windows.net",
"port": 6379,
"sslPort": 6380,
"minimumTlsVersion": "1.2",
"instances": [
{
"sslPort": 15000,
"nonSslPort": 13000,
"zone": "1",
"shardId": 0,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15001,
"nonSslPort": 13001,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15002,
"nonSslPort": 13002,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15003,
"nonSslPort": 13003,
"zone": "1",
"shardId": 1,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15004,
"nonSslPort": 13004,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15005,
"nonSslPort": 13005,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
}
]
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1",
"location": "West US",
"zones": [
"1"
],
"name": "cache1",
"type": "Microsoft.Cache/Redis",
"tags": {},
"properties": {
"accessKeys": {
"primaryKey": "<primaryKey>",
"secondaryKey": "<secondaryKey>"
},
"provisioningState": "Succeeded",
"redisVersion": "6.0.14",
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"enableNonSslPort": false,
"replicasPerMaster": 2,
"replicasPerPrimary": 2,
"updateChannel": "Stable",
"zonalAllocationPolicy": "UserDefined",
"redisConfiguration": {
"maxclients": "1000",
"maxmemory-reserved": "50",
"maxmemory-delta": "50"
},
"hostName": "cache1.redis.cache.windows.net",
"port": 6379,
"sslPort": 6380,
"minimumTlsVersion": "1.2",
"instances": [
{
"sslPort": 15000,
"nonSslPort": 13000,
"zone": "1",
"shardId": 0,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15001,
"nonSslPort": 13001,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15002,
"nonSslPort": 13002,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15003,
"nonSslPort": 13003,
"zone": "1",
"shardId": 1,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15004,
"nonSslPort": 13004,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15005,
"nonSslPort": 13005,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
}
]
}
}
RedisCacheCreateNoZonesZonalAllocationPolicy
Sample request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/redis/cache1?api-version=2024-11-01
{
"location": "East US",
"properties": {
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"enableNonSslPort": true,
"shardCount": 2,
"replicasPerPrimary": 2,
"zonalAllocationPolicy": "NoZones",
"redisConfiguration": {
"maxmemory-policy": "allkeys-lru"
},
"subnetId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
"staticIP": "192.168.0.5",
"minimumTlsVersion": "1.2"
}
}
import com.azure.resourcemanager.redis.models.RedisConfiguration;
import com.azure.resourcemanager.redis.models.RedisCreateParameters;
import com.azure.resourcemanager.redis.models.Sku;
import com.azure.resourcemanager.redis.models.SkuFamily;
import com.azure.resourcemanager.redis.models.SkuName;
import com.azure.resourcemanager.redis.models.TlsVersion;
import com.azure.resourcemanager.redis.models.ZonalAllocationPolicy;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Redis Create.
*/
public final class Main {
/*
* x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/
* RedisCacheCreateNoZonesZonalAllocationPolicy.json
*/
/**
* Sample code: RedisCacheCreateNoZonesZonalAllocationPolicy.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
redisCacheCreateNoZonesZonalAllocationPolicy(com.azure.resourcemanager.AzureResourceManager azure) {
azure.redisCaches().manager().serviceClient().getRedis().create("rg1", "cache1", new RedisCreateParameters()
.withLocation("East US")
.withSku(new Sku().withName(SkuName.PREMIUM).withFamily(SkuFamily.P).withCapacity(1))
.withSubnetId(
"/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1")
.withStaticIp("192.168.0.5")
.withRedisConfiguration(
new RedisConfiguration().withMaxmemoryPolicy("allkeys-lru").withAdditionalProperties(mapOf()))
.withEnableNonSslPort(true).withReplicasPerPrimary(2).withShardCount(2)
.withMinimumTlsVersion(TlsVersion.ONE_TWO).withZonalAllocationPolicy(ZonalAllocationPolicy.NO_ZONES),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.redis import RedisManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-redis
# USAGE
python redis_cache_create_no_zones_zonal_allocation_policy.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = RedisManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.redis.begin_create(
resource_group_name="rg1",
name="cache1",
parameters={
"location": "East US",
"properties": {
"enableNonSslPort": True,
"minimumTlsVersion": "1.2",
"redisConfiguration": {"maxmemory-policy": "allkeys-lru"},
"replicasPerPrimary": 2,
"shardCount": 2,
"sku": {"capacity": 1, "family": "P", "name": "Premium"},
"staticIP": "192.168.0.5",
"subnetId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
"zonalAllocationPolicy": "NoZones",
},
},
).result()
print(response)
# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateNoZonesZonalAllocationPolicy.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armredis_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redis/armredis/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/45374f48f560b3337ed55735038f1e9bf8cbea65/specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateNoZonesZonalAllocationPolicy.json
func ExampleClient_BeginCreate_redisCacheCreateNoZonesZonalAllocationPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armredis.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClient().BeginCreate(ctx, "rg1", "cache1", armredis.CreateParameters{
Location: to.Ptr("East US"),
Properties: &armredis.CreateProperties{
EnableNonSSLPort: to.Ptr(true),
MinimumTLSVersion: to.Ptr(armredis.TLSVersionOne2),
RedisConfiguration: &armredis.CommonPropertiesRedisConfiguration{
MaxmemoryPolicy: to.Ptr("allkeys-lru"),
},
ReplicasPerPrimary: to.Ptr[int32](2),
ShardCount: to.Ptr[int32](2),
ZonalAllocationPolicy: to.Ptr(armredis.ZonalAllocationPolicyNoZones),
SKU: &armredis.SKU{
Name: to.Ptr(armredis.SKUNamePremium),
Capacity: to.Ptr[int32](1),
Family: to.Ptr(armredis.SKUFamilyP),
},
StaticIP: to.Ptr("192.168.0.5"),
SubnetID: to.Ptr("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ResourceInfo = armredis.ResourceInfo{
// Name: to.Ptr("cache1"),
// Type: to.Ptr("Microsoft.Cache/Redis"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1"),
// Location: to.Ptr("East US"),
// Tags: map[string]*string{
// },
// Properties: &armredis.Properties{
// EnableNonSSLPort: to.Ptr(true),
// MinimumTLSVersion: to.Ptr(armredis.TLSVersionOne2),
// RedisConfiguration: &armredis.CommonPropertiesRedisConfiguration{
// Maxclients: to.Ptr("1000"),
// MaxmemoryDelta: to.Ptr("50"),
// MaxmemoryReserved: to.Ptr("50"),
// },
// RedisVersion: to.Ptr("6.0"),
// ReplicasPerMaster: to.Ptr[int32](2),
// ReplicasPerPrimary: to.Ptr[int32](2),
// ShardCount: to.Ptr[int32](2),
// UpdateChannel: to.Ptr(armredis.UpdateChannelStable),
// ZonalAllocationPolicy: to.Ptr(armredis.ZonalAllocationPolicyNoZones),
// SKU: &armredis.SKU{
// Name: to.Ptr(armredis.SKUNamePremium),
// Capacity: to.Ptr[int32](1),
// Family: to.Ptr(armredis.SKUFamilyP),
// },
// AccessKeys: &armredis.AccessKeys{
// PrimaryKey: to.Ptr("<primaryKey>"),
// SecondaryKey: to.Ptr("<secondaryKey>"),
// },
// HostName: to.Ptr("cache1.redis.cache.windows.net"),
// Instances: []*armredis.InstanceDetails{
// {
// IsMaster: to.Ptr(true),
// IsPrimary: to.Ptr(true),
// NonSSLPort: to.Ptr[int32](13000),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15000),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13001),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15001),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13002),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15002),
// },
// {
// IsMaster: to.Ptr(true),
// IsPrimary: to.Ptr(true),
// NonSSLPort: to.Ptr[int32](13003),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15003),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13004),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15004),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13005),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15005),
// }},
// Port: to.Ptr[int32](6379),
// ProvisioningState: to.Ptr(armredis.ProvisioningStateSucceeded),
// SSLPort: to.Ptr[int32](6380),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RedisManagementClient } = require("@azure/arm-rediscache");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
*
* @summary Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
* x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateNoZonesZonalAllocationPolicy.json
*/
async function redisCacheCreateNoZonesZonalAllocationPolicy() {
const subscriptionId = process.env["REDIS_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["REDIS_RESOURCE_GROUP"] || "rg1";
const name = "cache1";
const parameters = {
enableNonSslPort: true,
location: "East US",
minimumTlsVersion: "1.2",
redisConfiguration: { maxmemoryPolicy: "allkeys-lru" },
replicasPerPrimary: 2,
shardCount: 2,
sku: { name: "Premium", capacity: 1, family: "P" },
staticIP: "192.168.0.5",
subnetId:
"/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
zonalAllocationPolicy: "NoZones",
};
const credential = new DefaultAzureCredential();
const client = new RedisManagementClient(credential, subscriptionId);
const result = await client.redis.beginCreateAndWait(resourceGroupName, name, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Net;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Redis.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Redis;
// Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateNoZonesZonalAllocationPolicy.json
// this example is just showing the usage of "Redis_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this RedisResource
RedisCollection collection = resourceGroupResource.GetAllRedis();
// invoke the operation
string name = "cache1";
RedisCreateOrUpdateContent content = new RedisCreateOrUpdateContent(new AzureLocation("East US"), new RedisSku(RedisSkuName.Premium, RedisSkuFamily.Premium, 1))
{
RedisConfiguration = new RedisCommonConfiguration
{
MaxMemoryPolicy = "allkeys-lru",
},
EnableNonSslPort = true,
ReplicasPerPrimary = 2,
ShardCount = 2,
MinimumTlsVersion = RedisTlsVersion.Tls1_2,
ZonalAllocationPolicy = ZonalAllocationPolicy.NoZones,
SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1"),
StaticIP = IPAddress.Parse("192.168.0.5"),
};
ArmOperation<RedisResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, content);
RedisResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
RedisData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1",
"location": "East US",
"name": "cache1",
"type": "Microsoft.Cache/Redis",
"tags": {},
"properties": {
"accessKeys": {
"primaryKey": "<primaryKey>",
"secondaryKey": "<secondaryKey>"
},
"provisioningState": "Succeeded",
"redisVersion": "6.0",
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"shardCount": 2,
"enableNonSslPort": true,
"replicasPerMaster": 2,
"replicasPerPrimary": 2,
"updateChannel": "Stable",
"zonalAllocationPolicy": "NoZones",
"redisConfiguration": {
"maxmemory-policy": "allkeys-lru"
},
"hostName": "cache1.redis.cache.windows.net",
"port": 6379,
"sslPort": 6380,
"minimumTlsVersion": "1.2",
"instances": [
{
"sslPort": 15000,
"nonSslPort": 13000,
"shardId": 0,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15001,
"nonSslPort": 13001,
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15002,
"nonSslPort": 13002,
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15003,
"nonSslPort": 13003,
"shardId": 1,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15004,
"nonSslPort": 13004,
"shardId": 1,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15005,
"nonSslPort": 13005,
"shardId": 1,
"isMaster": false,
"isPrimary": false
}
]
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1",
"location": "East US",
"name": "cache1",
"type": "Microsoft.Cache/Redis",
"tags": {},
"properties": {
"accessKeys": {
"primaryKey": "<primaryKey>",
"secondaryKey": "<secondaryKey>"
},
"provisioningState": "Succeeded",
"redisVersion": "6.0",
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"shardCount": 2,
"enableNonSslPort": true,
"replicasPerMaster": 2,
"replicasPerPrimary": 2,
"updateChannel": "Stable",
"zonalAllocationPolicy": "NoZones",
"redisConfiguration": {
"maxclients": "1000",
"maxmemory-reserved": "50",
"maxmemory-delta": "50"
},
"hostName": "cache1.redis.cache.windows.net",
"port": 6379,
"sslPort": 6380,
"minimumTlsVersion": "1.2",
"instances": [
{
"sslPort": 15000,
"nonSslPort": 13000,
"shardId": 0,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15001,
"nonSslPort": 13001,
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15002,
"nonSslPort": 13002,
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15003,
"nonSslPort": 13003,
"shardId": 1,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15004,
"nonSslPort": 13004,
"shardId": 1,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15005,
"nonSslPort": 13005,
"shardId": 1,
"isMaster": false,
"isPrimary": false
}
]
}
}
RedisCacheCreateUserDefinedZonalAllocationPolicy
Sample request
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/redis/cache1?api-version=2024-11-01
{
"location": "East US",
"zones": [
"1"
],
"properties": {
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"redisVersion": "Latest",
"enableNonSslPort": true,
"shardCount": 2,
"replicasPerPrimary": 2,
"zonalAllocationPolicy": "UserDefined",
"redisConfiguration": {
"maxmemory-policy": "allkeys-lru"
},
"subnetId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
"staticIP": "192.168.0.5",
"minimumTlsVersion": "1.2"
}
}
import com.azure.resourcemanager.redis.models.RedisConfiguration;
import com.azure.resourcemanager.redis.models.RedisCreateParameters;
import com.azure.resourcemanager.redis.models.Sku;
import com.azure.resourcemanager.redis.models.SkuFamily;
import com.azure.resourcemanager.redis.models.SkuName;
import com.azure.resourcemanager.redis.models.TlsVersion;
import com.azure.resourcemanager.redis.models.ZonalAllocationPolicy;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Redis Create.
*/
public final class Main {
/*
* x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/
* RedisCacheCreateUserDefinedZonalAllocationPolicy.json
*/
/**
* Sample code: RedisCacheCreateUserDefinedZonalAllocationPolicy.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
redisCacheCreateUserDefinedZonalAllocationPolicy(com.azure.resourcemanager.AzureResourceManager azure) {
azure.redisCaches().manager().serviceClient().getRedis().create("rg1", "cache1", new RedisCreateParameters()
.withZones(Arrays.asList("1")).withLocation("East US")
.withSku(new Sku().withName(SkuName.PREMIUM).withFamily(SkuFamily.P).withCapacity(1))
.withSubnetId(
"/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1")
.withStaticIp("192.168.0.5")
.withRedisConfiguration(
new RedisConfiguration().withMaxmemoryPolicy("allkeys-lru").withAdditionalProperties(mapOf()))
.withRedisVersion("Latest").withEnableNonSslPort(true).withReplicasPerPrimary(2).withShardCount(2)
.withMinimumTlsVersion(TlsVersion.ONE_TWO).withZonalAllocationPolicy(ZonalAllocationPolicy.USER_DEFINED),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.redis import RedisManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-redis
# USAGE
python redis_cache_create_user_defined_zonal_allocation_policy.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = RedisManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.redis.begin_create(
resource_group_name="rg1",
name="cache1",
parameters={
"location": "East US",
"properties": {
"enableNonSslPort": True,
"minimumTlsVersion": "1.2",
"redisConfiguration": {"maxmemory-policy": "allkeys-lru"},
"redisVersion": "Latest",
"replicasPerPrimary": 2,
"shardCount": 2,
"sku": {"capacity": 1, "family": "P", "name": "Premium"},
"staticIP": "192.168.0.5",
"subnetId": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
"zonalAllocationPolicy": "UserDefined",
},
"zones": ["1"],
},
).result()
print(response)
# x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateUserDefinedZonalAllocationPolicy.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armredis_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redis/armredis/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/45374f48f560b3337ed55735038f1e9bf8cbea65/specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateUserDefinedZonalAllocationPolicy.json
func ExampleClient_BeginCreate_redisCacheCreateUserDefinedZonalAllocationPolicy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armredis.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewClient().BeginCreate(ctx, "rg1", "cache1", armredis.CreateParameters{
Location: to.Ptr("East US"),
Properties: &armredis.CreateProperties{
EnableNonSSLPort: to.Ptr(true),
MinimumTLSVersion: to.Ptr(armredis.TLSVersionOne2),
RedisConfiguration: &armredis.CommonPropertiesRedisConfiguration{
MaxmemoryPolicy: to.Ptr("allkeys-lru"),
},
RedisVersion: to.Ptr("Latest"),
ReplicasPerPrimary: to.Ptr[int32](2),
ShardCount: to.Ptr[int32](2),
ZonalAllocationPolicy: to.Ptr(armredis.ZonalAllocationPolicyUserDefined),
SKU: &armredis.SKU{
Name: to.Ptr(armredis.SKUNamePremium),
Capacity: to.Ptr[int32](1),
Family: to.Ptr(armredis.SKUFamilyP),
},
StaticIP: to.Ptr("192.168.0.5"),
SubnetID: to.Ptr("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1"),
},
Zones: []*string{
to.Ptr("1")},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ResourceInfo = armredis.ResourceInfo{
// Name: to.Ptr("cache1"),
// Type: to.Ptr("Microsoft.Cache/Redis"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1"),
// Location: to.Ptr("East US"),
// Tags: map[string]*string{
// },
// Properties: &armredis.Properties{
// EnableNonSSLPort: to.Ptr(false),
// MinimumTLSVersion: to.Ptr(armredis.TLSVersionOne2),
// RedisConfiguration: &armredis.CommonPropertiesRedisConfiguration{
// Maxclients: to.Ptr("1000"),
// MaxmemoryDelta: to.Ptr("50"),
// MaxmemoryReserved: to.Ptr("50"),
// },
// RedisVersion: to.Ptr("6.0.14"),
// ReplicasPerMaster: to.Ptr[int32](2),
// ReplicasPerPrimary: to.Ptr[int32](2),
// UpdateChannel: to.Ptr(armredis.UpdateChannelStable),
// ZonalAllocationPolicy: to.Ptr(armredis.ZonalAllocationPolicyUserDefined),
// SKU: &armredis.SKU{
// Name: to.Ptr(armredis.SKUNamePremium),
// Capacity: to.Ptr[int32](1),
// Family: to.Ptr(armredis.SKUFamilyP),
// },
// AccessKeys: &armredis.AccessKeys{
// PrimaryKey: to.Ptr("<primaryKey>"),
// SecondaryKey: to.Ptr("<secondaryKey>"),
// },
// HostName: to.Ptr("cache1.redis.cache.windows.net"),
// Instances: []*armredis.InstanceDetails{
// {
// IsMaster: to.Ptr(true),
// IsPrimary: to.Ptr(true),
// NonSSLPort: to.Ptr[int32](13000),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15000),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13001),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15001),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13002),
// ShardID: to.Ptr[int32](0),
// SSLPort: to.Ptr[int32](15002),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(true),
// IsPrimary: to.Ptr(true),
// NonSSLPort: to.Ptr[int32](13003),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15003),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13004),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15004),
// Zone: to.Ptr("1"),
// },
// {
// IsMaster: to.Ptr(false),
// IsPrimary: to.Ptr(false),
// NonSSLPort: to.Ptr[int32](13005),
// ShardID: to.Ptr[int32](1),
// SSLPort: to.Ptr[int32](15005),
// Zone: to.Ptr("1"),
// }},
// Port: to.Ptr[int32](6379),
// ProvisioningState: to.Ptr(armredis.ProvisioningStateSucceeded),
// SSLPort: to.Ptr[int32](6380),
// },
// Zones: []*string{
// to.Ptr("1")},
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { RedisManagementClient } = require("@azure/arm-rediscache");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
* This sample demonstrates how to Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
*
* @summary Create or replace (overwrite/recreate, with potential downtime) an existing Redis cache.
* x-ms-original-file: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateUserDefinedZonalAllocationPolicy.json
*/
async function redisCacheCreateUserDefinedZonalAllocationPolicy() {
const subscriptionId = process.env["REDIS_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["REDIS_RESOURCE_GROUP"] || "rg1";
const name = "cache1";
const parameters = {
enableNonSslPort: true,
location: "East US",
minimumTlsVersion: "1.2",
redisConfiguration: { maxmemoryPolicy: "allkeys-lru" },
redisVersion: "Latest",
replicasPerPrimary: 2,
shardCount: 2,
sku: { name: "Premium", capacity: 1, family: "P" },
staticIP: "192.168.0.5",
subnetId:
"/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1",
zonalAllocationPolicy: "UserDefined",
zones: ["1"],
};
const credential = new DefaultAzureCredential();
const client = new RedisManagementClient(credential, subscriptionId);
const result = await client.redis.beginCreateAndWait(resourceGroupName, name, parameters);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Net;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Redis.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Redis;
// Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-11-01/examples/RedisCacheCreateUserDefinedZonalAllocationPolicy.json
// this example is just showing the usage of "Redis_Create" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this RedisResource
RedisCollection collection = resourceGroupResource.GetAllRedis();
// invoke the operation
string name = "cache1";
RedisCreateOrUpdateContent content = new RedisCreateOrUpdateContent(new AzureLocation("East US"), new RedisSku(RedisSkuName.Premium, RedisSkuFamily.Premium, 1))
{
Zones = { "1" },
RedisConfiguration = new RedisCommonConfiguration
{
MaxMemoryPolicy = "allkeys-lru",
},
RedisVersion = "Latest",
EnableNonSslPort = true,
ReplicasPerPrimary = 2,
ShardCount = 2,
MinimumTlsVersion = RedisTlsVersion.Tls1_2,
ZonalAllocationPolicy = ZonalAllocationPolicy.UserDefined,
SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/network1/subnets/subnet1"),
StaticIP = IPAddress.Parse("192.168.0.5"),
};
ArmOperation<RedisResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, content);
RedisResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
RedisData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1",
"location": "East US",
"zones": [
"1"
],
"name": "cache1",
"type": "Microsoft.Cache/Redis",
"tags": {},
"properties": {
"accessKeys": {
"primaryKey": "<primaryKey>",
"secondaryKey": "<secondaryKey>"
},
"provisioningState": "Succeeded",
"redisVersion": "6.0.14",
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"enableNonSslPort": false,
"replicasPerMaster": 2,
"replicasPerPrimary": 2,
"updateChannel": "Stable",
"zonalAllocationPolicy": "UserDefined",
"redisConfiguration": {
"maxmemory-policy": "allkeys-lru"
},
"hostName": "cache1.redis.cache.windows.net",
"port": 6379,
"sslPort": 6380,
"minimumTlsVersion": "1.2",
"instances": [
{
"sslPort": 15000,
"nonSslPort": 13000,
"zone": "1",
"shardId": 0,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15001,
"nonSslPort": 13001,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15002,
"nonSslPort": 13002,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15003,
"nonSslPort": 13003,
"zone": "1",
"shardId": 1,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15004,
"nonSslPort": 13004,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15005,
"nonSslPort": 13005,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
}
]
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache1",
"location": "East US",
"zones": [
"1"
],
"name": "cache1",
"type": "Microsoft.Cache/Redis",
"tags": {},
"properties": {
"accessKeys": {
"primaryKey": "<primaryKey>",
"secondaryKey": "<secondaryKey>"
},
"provisioningState": "Succeeded",
"redisVersion": "6.0.14",
"sku": {
"name": "Premium",
"family": "P",
"capacity": 1
},
"enableNonSslPort": false,
"replicasPerMaster": 2,
"replicasPerPrimary": 2,
"updateChannel": "Stable",
"zonalAllocationPolicy": "UserDefined",
"redisConfiguration": {
"maxclients": "1000",
"maxmemory-reserved": "50",
"maxmemory-delta": "50"
},
"hostName": "cache1.redis.cache.windows.net",
"port": 6379,
"sslPort": 6380,
"minimumTlsVersion": "1.2",
"instances": [
{
"sslPort": 15000,
"nonSslPort": 13000,
"zone": "1",
"shardId": 0,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15001,
"nonSslPort": 13001,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15002,
"nonSslPort": 13002,
"zone": "1",
"shardId": 0,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15003,
"nonSslPort": 13003,
"zone": "1",
"shardId": 1,
"isMaster": true,
"isPrimary": true
},
{
"sslPort": 15004,
"nonSslPort": 13004,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
},
{
"sslPort": 15005,
"nonSslPort": 13005,
"zone": "1",
"shardId": 1,
"isMaster": false,
"isPrimary": false
}
]
}
}
Definitions
Name |
Description |
ErrorAdditionalInfo
|
The resource management error additional info.
|
ErrorDetail
|
The error detail.
|
ErrorResponse
|
Error response
|
ManagedServiceIdentity
|
Managed service identity (system assigned and/or user assigned identities)
|
ManagedServiceIdentityType
|
Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).
|
PrivateEndpoint
|
The Private Endpoint resource.
|
PrivateEndpointConnection
|
The Private Endpoint Connection resource.
|
PrivateEndpointConnectionProvisioningState
|
The current provisioning state.
|
PrivateEndpointServiceConnectionStatus
|
The private endpoint connection status.
|
PrivateLinkServiceConnectionState
|
A collection of information about the state of the connection between service consumer and provider.
|
ProvisioningState
|
Redis instance provisioning status.
|
PublicNetworkAccess
|
Whether or not public endpoint access is allowed for this cache. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'
|
RedisAccessKeys
|
Redis cache access keys.
|
RedisConfiguration
|
All Redis Settings. Few possible keys: rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta, maxmemory-policy,notify-keyspace-events, aof-backup-enabled, aof-storage-connection-string-0, aof-storage-connection-string-1 etc.
|
RedisCreateParameters
|
Parameters supplied to the Create Redis operation.
|
RedisInstanceDetails
|
Details of single instance of redis.
|
RedisLinkedServer
|
Linked server Id
|
RedisResource
|
A single Redis item in List or Get Operation.
|
Sku
|
SKU parameters supplied to the create Redis operation.
|
SkuFamily
|
The SKU family to use. Valid values: (C, P). (C = Basic/Standard, P = Premium).
|
SkuName
|
The type of Redis cache to deploy. Valid values: (Basic, Standard, Premium)
|
TlsVersion
|
Optional: requires clients to use a specified TLS version (or higher) to connect (e,g, '1.0', '1.1', '1.2')
|
UpdateChannel
|
Optional: Specifies the update channel for the monthly Redis updates your Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates at least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'.
|
UserAssignedIdentity
|
User assigned identity properties
|
ZonalAllocationPolicy
|
Optional: Specifies how availability zones are allocated to the Redis cache. 'Automatic' enables zone redundancy and Azure will automatically select zones based on regional availability and capacity. 'UserDefined' will select availability zones passed in by you using the 'zones' parameter. 'NoZones' will produce a non-zonal cache. If 'zonalAllocationPolicy' is not passed, it will be set to 'UserDefined' when zones are passed in, otherwise, it will be set to 'Automatic' in regions where zones are supported and 'NoZones' in regions where zones are not supported.
|
ErrorAdditionalInfo
Object
The resource management error additional info.
Name |
Type |
Description |
info
|
object
|
The additional info.
|
type
|
string
|
The additional info type.
|
ErrorDetail
Object
The error detail.
Name |
Type |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
The error additional info.
|
code
|
string
|
The error code.
|
details
|
ErrorDetail[]
|
The error details.
|
message
|
string
|
The error message.
|
target
|
string
|
The error target.
|
ErrorResponse
Object
Error response
Name |
Type |
Description |
error
|
ErrorDetail
|
The error object.
|
ManagedServiceIdentity
Object
Managed service identity (system assigned and/or user assigned identities)
Name |
Type |
Description |
principalId
|
string
(uuid)
|
The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity.
|
tenantId
|
string
(uuid)
|
The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity.
|
type
|
ManagedServiceIdentityType
|
Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).
|
userAssignedIdentities
|
<string,
UserAssignedIdentity>
|
User-Assigned Identities
The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.
|
ManagedServiceIdentityType
Enumeration
Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).
Value |
Description |
None
|
|
SystemAssigned
|
|
SystemAssigned, UserAssigned
|
|
UserAssigned
|
|
PrivateEndpoint
Object
The Private Endpoint resource.
Name |
Type |
Description |
id
|
string
|
The ARM identifier for Private Endpoint
|
PrivateEndpointConnection
Object
The Private Endpoint Connection resource.
Name |
Type |
Description |
id
|
string
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
The name of the resource
|
properties.privateEndpoint
|
PrivateEndpoint
|
The resource of private end point.
|
properties.privateLinkServiceConnectionState
|
PrivateLinkServiceConnectionState
|
A collection of information about the state of the connection between service consumer and provider.
|
properties.provisioningState
|
PrivateEndpointConnectionProvisioningState
|
The provisioning state of the private endpoint connection resource.
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
PrivateEndpointConnectionProvisioningState
Enumeration
The current provisioning state.
Value |
Description |
Creating
|
|
Deleting
|
|
Failed
|
|
Succeeded
|
|
PrivateEndpointServiceConnectionStatus
Enumeration
The private endpoint connection status.
Value |
Description |
Approved
|
|
Pending
|
|
Rejected
|
|
PrivateLinkServiceConnectionState
Object
A collection of information about the state of the connection between service consumer and provider.
Name |
Type |
Description |
actionsRequired
|
string
|
A message indicating if changes on the service provider require any updates on the consumer.
|
description
|
string
|
The reason for approval/rejection of the connection.
|
status
|
PrivateEndpointServiceConnectionStatus
|
Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service.
|
ProvisioningState
Enumeration
Redis instance provisioning status.
Value |
Description |
ConfiguringAAD
|
|
Creating
|
|
Deleting
|
|
Disabled
|
|
Failed
|
|
Linking
|
|
Provisioning
|
|
RecoveringScaleFailure
|
|
Scaling
|
|
Succeeded
|
|
Unlinking
|
|
Unprovisioning
|
|
Updating
|
|
PublicNetworkAccess
Enumeration
Whether or not public endpoint access is allowed for this cache. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'
Value |
Description |
Disabled
|
|
Enabled
|
|
RedisAccessKeys
Object
Redis cache access keys.
Name |
Type |
Description |
primaryKey
|
string
|
The current primary key that clients can use to authenticate with Redis cache.
|
secondaryKey
|
string
|
The current secondary key that clients can use to authenticate with Redis cache.
|
RedisConfiguration
Object
All Redis Settings. Few possible keys: rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta, maxmemory-policy,notify-keyspace-events, aof-backup-enabled, aof-storage-connection-string-0, aof-storage-connection-string-1 etc.
Name |
Type |
Description |
aad-enabled
|
string
|
Specifies whether AAD based authentication has been enabled or disabled for the cache
|
aof-backup-enabled
|
string
|
Specifies whether the aof backup is enabled
|
aof-storage-connection-string-0
|
string
|
First storage account connection string
|
aof-storage-connection-string-1
|
string
|
Second storage account connection string
|
authnotrequired
|
string
|
Specifies whether the authentication is disabled. Setting this property is highly discouraged from security point of view.
|
maxclients
|
string
|
The max clients config
|
maxfragmentationmemory-reserved
|
string
|
Value in megabytes reserved for fragmentation per shard
|
maxmemory-delta
|
string
|
Value in megabytes reserved for non-cache usage per shard e.g. failover.
|
maxmemory-policy
|
string
|
The eviction strategy used when your data won't fit within its memory limit.
|
maxmemory-reserved
|
string
|
Value in megabytes reserved for non-cache usage per shard e.g. failover.
|
notify-keyspace-events
|
string
|
The keyspace events which should be monitored.
|
preferred-data-archive-auth-method
|
string
|
Preferred auth method to communicate to storage account used for data archive, specify SAS or ManagedIdentity, default value is SAS
|
preferred-data-persistence-auth-method
|
string
|
Preferred auth method to communicate to storage account used for data persistence, specify SAS or ManagedIdentity, default value is SAS
|
rdb-backup-enabled
|
string
|
Specifies whether the rdb backup is enabled
|
rdb-backup-frequency
|
string
|
Specifies the frequency for creating rdb backup in minutes. Valid values: (15, 30, 60, 360, 720, 1440)
|
rdb-backup-max-snapshot-count
|
string
|
Specifies the maximum number of snapshots for rdb backup
|
rdb-storage-connection-string
|
string
|
The storage account connection string for storing rdb file
|
storage-subscription-id
|
string
|
SubscriptionId of the storage account for persistence (aof/rdb) using ManagedIdentity.
|
zonal-configuration
|
string
|
Zonal Configuration
|
RedisCreateParameters
Object
Parameters supplied to the Create Redis operation.
Name |
Type |
Default value |
Description |
identity
|
ManagedServiceIdentity
|
|
The identity of the resource.
|
location
|
string
|
|
The geo-location where the resource lives
|
properties.disableAccessKeyAuthentication
|
boolean
|
False
|
Authentication to Redis through access keys is disabled when set as true. Default value is false.
|
properties.enableNonSslPort
|
boolean
|
False
|
Specifies whether the non-ssl Redis server port (6379) is enabled.
|
properties.minimumTlsVersion
|
TlsVersion
|
|
Optional: requires clients to use a specified TLS version (or higher) to connect (e,g, '1.0', '1.1', '1.2')
|
properties.publicNetworkAccess
|
PublicNetworkAccess
|
Enabled
|
Whether or not public endpoint access is allowed for this cache. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'
|
properties.redisConfiguration
|
RedisConfiguration
|
|
All Redis Settings. Few possible keys: rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta, maxmemory-policy,notify-keyspace-events, aof-backup-enabled, aof-storage-connection-string-0, aof-storage-connection-string-1 etc.
|
properties.redisVersion
|
string
|
|
Redis version. This should be in the form 'major[.minor]' (only 'major' is required) or the value 'latest' which refers to the latest stable Redis version that is available. Supported versions: 4.0, 6.0 (latest). Default value is 'latest'.
|
properties.replicasPerMaster
|
integer
(int32)
|
|
The number of replicas to be created per primary.
|
properties.replicasPerPrimary
|
integer
(int32)
|
|
The number of replicas to be created per primary.
|
properties.shardCount
|
integer
(int32)
|
|
The number of shards to be created on a Premium Cluster Cache.
|
properties.sku
|
Sku
|
|
The SKU of the Redis cache to deploy.
|
properties.staticIP
|
string
pattern: ^\d+\.\d+\.\d+\.\d+$
|
|
Static IP address. Optionally, may be specified when deploying a Redis cache inside an existing Azure Virtual Network; auto assigned by default.
|
properties.subnetId
|
string
pattern: ^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$
|
|
The full resource ID of a subnet in a virtual network to deploy the Redis cache in. Example format: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1
|
properties.tenantSettings
|
object
|
|
A dictionary of tenant settings
|
properties.updateChannel
|
UpdateChannel
|
|
Optional: Specifies the update channel for the monthly Redis updates your Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates at least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'.
|
properties.zonalAllocationPolicy
|
ZonalAllocationPolicy
|
|
Optional: Specifies how availability zones are allocated to the Redis cache. 'Automatic' enables zone redundancy and Azure will automatically select zones based on regional availability and capacity. 'UserDefined' will select availability zones passed in by you using the 'zones' parameter. 'NoZones' will produce a non-zonal cache. If 'zonalAllocationPolicy' is not passed, it will be set to 'UserDefined' when zones are passed in, otherwise, it will be set to 'Automatic' in regions where zones are supported and 'NoZones' in regions where zones are not supported.
|
tags
|
object
|
|
Resource tags.
|
zones
|
string[]
|
|
A list of availability zones denoting where the resource needs to come from.
|
RedisInstanceDetails
Object
Details of single instance of redis.
Name |
Type |
Description |
isMaster
|
boolean
|
Specifies whether the instance is a primary node.
|
isPrimary
|
boolean
|
Specifies whether the instance is a primary node.
|
nonSslPort
|
integer
(int32)
|
If enableNonSslPort is true, provides Redis instance Non-SSL port.
|
shardId
|
integer
(int32)
|
If clustering is enabled, the Shard ID of Redis Instance
|
sslPort
|
integer
(int32)
|
Redis instance SSL port.
|
zone
|
string
|
If the Cache uses availability zones, specifies availability zone where this instance is located.
|
RedisLinkedServer
Object
Linked server Id
Name |
Type |
Description |
id
|
string
|
Linked server Id.
|
RedisResource
Object
A single Redis item in List or Get Operation.
Name |
Type |
Default value |
Description |
disableAccessKeyAuthentication
|
boolean
|
False
|
Authentication to Redis through access keys is disabled when set as true. Default value is false.
|
enableNonSslPort
|
boolean
|
False
|
Specifies whether the non-ssl Redis server port (6379) is enabled.
|
id
|
string
|
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
identity
|
ManagedServiceIdentity
|
|
The identity of the resource.
|
location
|
string
|
|
The geo-location where the resource lives
|
minimumTlsVersion
|
TlsVersion
|
|
Optional: requires clients to use a specified TLS version (or higher) to connect (e,g, '1.0', '1.1', '1.2')
|
name
|
string
|
|
The name of the resource
|
properties.accessKeys
|
RedisAccessKeys
|
|
The keys of the Redis cache - not set if this object is not the response to Create or Update redis cache
|
properties.hostName
|
string
|
|
Redis host name.
|
properties.instances
|
RedisInstanceDetails[]
|
|
List of the Redis instances associated with the cache
|
properties.linkedServers
|
RedisLinkedServer[]
|
|
List of the linked servers associated with the cache
|
properties.port
|
integer
(int32)
|
|
Redis non-SSL port.
|
properties.privateEndpointConnections
|
PrivateEndpointConnection[]
|
|
List of private endpoint connection associated with the specified redis cache
|
properties.provisioningState
|
ProvisioningState
|
|
Redis instance provisioning status.
|
properties.sku
|
Sku
|
|
The SKU of the Redis cache to deploy.
|
properties.sslPort
|
integer
(int32)
|
|
Redis SSL port.
|
properties.staticIP
|
string
pattern: ^\d+\.\d+\.\d+\.\d+$
|
|
Static IP address. Optionally, may be specified when deploying a Redis cache inside an existing Azure Virtual Network; auto assigned by default.
|
properties.subnetId
|
string
pattern: ^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$
|
|
The full resource ID of a subnet in a virtual network to deploy the Redis cache in. Example format: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Microsoft.{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1
|
publicNetworkAccess
|
PublicNetworkAccess
|
Enabled
|
Whether or not public endpoint access is allowed for this cache. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. If 'Disabled', private endpoints are the exclusive access method. Default value is 'Enabled'
|
redisConfiguration
|
RedisConfiguration
|
|
All Redis Settings. Few possible keys: rdb-backup-enabled,rdb-storage-connection-string,rdb-backup-frequency,maxmemory-delta, maxmemory-policy,notify-keyspace-events, aof-backup-enabled, aof-storage-connection-string-0, aof-storage-connection-string-1 etc.
|
redisVersion
|
string
|
|
Redis version. This should be in the form 'major[.minor]' (only 'major' is required) or the value 'latest' which refers to the latest stable Redis version that is available. Supported versions: 4.0, 6.0 (latest). Default value is 'latest'.
|
replicasPerMaster
|
integer
(int32)
|
|
The number of replicas to be created per primary.
|
replicasPerPrimary
|
integer
(int32)
|
|
The number of replicas to be created per primary.
|
shardCount
|
integer
(int32)
|
|
The number of shards to be created on a Premium Cluster Cache.
|
tags
|
object
|
|
Resource tags.
|
tenantSettings
|
object
|
|
A dictionary of tenant settings
|
type
|
string
|
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
updateChannel
|
UpdateChannel
|
|
Optional: Specifies the update channel for the monthly Redis updates your Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates at least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'.
|
zonalAllocationPolicy
|
ZonalAllocationPolicy
|
|
Optional: Specifies how availability zones are allocated to the Redis cache. 'Automatic' enables zone redundancy and Azure will automatically select zones based on regional availability and capacity. 'UserDefined' will select availability zones passed in by you using the 'zones' parameter. 'NoZones' will produce a non-zonal cache. If 'zonalAllocationPolicy' is not passed, it will be set to 'UserDefined' when zones are passed in, otherwise, it will be set to 'Automatic' in regions where zones are supported and 'NoZones' in regions where zones are not supported.
|
zones
|
string[]
|
|
A list of availability zones denoting where the resource needs to come from.
|
Sku
Object
SKU parameters supplied to the create Redis operation.
Name |
Type |
Description |
capacity
|
integer
(int32)
|
The size of the Redis cache to deploy. Valid values: for C (Basic/Standard) family (0, 1, 2, 3, 4, 5, 6), for P (Premium) family (1, 2, 3, 4).
|
family
|
SkuFamily
|
The SKU family to use. Valid values: (C, P). (C = Basic/Standard, P = Premium).
|
name
|
SkuName
|
The type of Redis cache to deploy. Valid values: (Basic, Standard, Premium)
|
SkuFamily
Enumeration
The SKU family to use. Valid values: (C, P). (C = Basic/Standard, P = Premium).
SkuName
Enumeration
The type of Redis cache to deploy. Valid values: (Basic, Standard, Premium)
Value |
Description |
Basic
|
|
Premium
|
|
Standard
|
|
TlsVersion
Enumeration
Optional: requires clients to use a specified TLS version (or higher) to connect (e,g, '1.0', '1.1', '1.2')
Value |
Description |
1.0
|
|
1.1
|
|
1.2
|
|
UpdateChannel
Enumeration
Optional: Specifies the update channel for the monthly Redis updates your Redis Cache will receive. Caches using 'Preview' update channel get latest Redis updates at least 4 weeks ahead of 'Stable' channel caches. Default value is 'Stable'.
Value |
Description |
Preview
|
|
Stable
|
|
UserAssignedIdentity
Object
User assigned identity properties
Name |
Type |
Description |
clientId
|
string
(uuid)
|
The client ID of the assigned identity.
|
principalId
|
string
(uuid)
|
The principal ID of the assigned identity.
|
ZonalAllocationPolicy
Enumeration
Optional: Specifies how availability zones are allocated to the Redis cache. 'Automatic' enables zone redundancy and Azure will automatically select zones based on regional availability and capacity. 'UserDefined' will select availability zones passed in by you using the 'zones' parameter. 'NoZones' will produce a non-zonal cache. If 'zonalAllocationPolicy' is not passed, it will be set to 'UserDefined' when zones are passed in, otherwise, it will be set to 'Automatic' in regions where zones are supported and 'NoZones' in regions where zones are not supported.
Value |
Description |
Automatic
|
|
NoZones
|
|
UserDefined
|
|