创建或替换现有 Redis 缓存(覆盖/重新创建,并可能停机)。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}?api-version=2024-11-01
URI 参数
名称 |
在 |
必需 |
类型 |
说明 |
name
|
path |
True
|
string
|
Redis 缓存的名称。
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
资源组的名称。 名称不区分大小写。
|
subscriptionId
|
path |
True
|
string
minLength: 1
|
目标订阅的 ID。
|
api-version
|
query |
True
|
string
minLength: 1
|
用于此操作的 API 版本。
|
请求正文
名称 |
必需 |
类型 |
说明 |
location
|
True
|
string
|
资源所在的地理位置
|
properties.sku
|
True
|
Sku
|
要部署的 Redis 缓存的 SKU。
|
identity
|
|
ManagedServiceIdentity
|
资源的标识。
|
properties.disableAccessKeyAuthentication
|
|
boolean
|
如果设置为 true,则会禁用通过访问密钥向 Redis 进行身份验证。 默认值为 false。
|
properties.enableNonSslPort
|
|
boolean
|
指定是否启用非 ssl Redis 服务器端口(6379)。
|
properties.minimumTlsVersion
|
|
TlsVersion
|
可选:要求客户端使用指定的 TLS 版本(或更高版本)进行连接(例如,“1.0”、“1.1”、“1.2”)
|
properties.publicNetworkAccess
|
|
PublicNetworkAccess
|
是否允许对此缓存使用公共终结点访问。 值是可选的,但如果传入,则必须为“Enabled”或“Disabled”。 如果为“Disabled”,则专用终结点是独占访问方法。 默认值为“Enabled”
|
properties.redisConfiguration
|
|
RedisConfiguration
|
所有 Redis 设置。 很少有可能的密钥: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 等。
|
properties.redisVersion
|
|
string
|
Redis 版本。 这应采用“major[.minor]”(仅需要“major”)或值“latest”,该值引用可用的最新稳定 Redis 版本。 支持的版本:4.0、6.0(最新版)。 默认值为“latest”。
|
properties.replicasPerMaster
|
|
integer
(int32)
|
要为每个主要副本创建的副本数。
|
properties.replicasPerPrimary
|
|
integer
(int32)
|
要为每个主要副本创建的副本数。
|
properties.shardCount
|
|
integer
(int32)
|
在高级群集缓存上创建的分片数。
|
properties.staticIP
|
|
string
pattern: ^\d+\.\d+\.\d+\.\d+$
|
静态 IP 地址。 (可选)在现有 Azure 虚拟网络中部署 Redis 缓存时可以指定;默认情况下自动分配。
|
properties.subnetId
|
|
string
pattern: ^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$
|
要在其中部署 Redis 缓存的虚拟网络中子网的完整资源 ID。 示例格式:/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Microsoft。{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1
|
properties.tenantSettings
|
|
object
|
租户设置字典
|
properties.updateChannel
|
|
UpdateChannel
|
可选:指定 Redis 缓存将接收的每月 Redis 更新的更新通道。 使用“预览”更新通道的缓存在“稳定”通道缓存之前至少提前 4 周获取最新的 Redis 更新。 默认值为“Stable”。
|
properties.zonalAllocationPolicy
|
|
ZonalAllocationPolicy
|
可选:指定如何将可用性区域分配给 Redis 缓存。 “自动”启用区域冗余,Azure 将根据区域可用性和容量自动选择区域。 “UserDefined”将使用“zone”参数选择传入的可用性区域。 “NoZones”将生成非区域性缓存。 如果未传递“zonalAllocationPolicy”,则会在传入区域时将其设置为“UserDefined”,否则,在不支持区域的区域中,将设置为“自动”,在不支持区域的区域中将其设置为“NoZones”。
|
tags
|
|
object
|
资源标记。
|
zones
|
|
string[]
|
一个可用性区域列表,表示资源需要来自何处。
|
响应
名称 |
类型 |
说明 |
200 OK
|
RedisResource
|
已成功更新现有的 redis 缓存。 检查 provisioningState 以查看详细状态。
|
201 Created
|
RedisResource
|
已成功创建新的 redis 缓存。 检查 provisioningState 以查看详细状态。
|
Other Status Codes
|
ErrorResponse
|
描述操作失败的原因的错误响应。
|
安全性
azure_auth
Azure Active Directory OAuth2 Flow。
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
名称 |
说明 |
user_impersonation
|
模拟用户帐户
|
示例
RedisCacheCreate
示例请求
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
示例响应
{
"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
示例请求
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
示例响应
{
"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
示例请求
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
示例响应
{
"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
示例请求
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
示例响应
{
"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
示例请求
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
示例响应
{
"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
示例请求
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
示例响应
{
"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
}
]
}
}
定义
ErrorAdditionalInfo
Object
资源管理错误附加信息。
名称 |
类型 |
说明 |
info
|
object
|
其他信息。
|
type
|
string
|
其他信息类型。
|
ErrorDetail
Object
错误详细信息。
ErrorResponse
Object
错误响应
ManagedServiceIdentity
Object
托管服务标识(系统分配和/或用户分配的标识)
名称 |
类型 |
说明 |
principalId
|
string
(uuid)
|
系统分配标识的服务主体 ID。 此属性仅针对系统分配的标识提供。
|
tenantId
|
string
(uuid)
|
系统分配标识的租户 ID。 此属性仅针对系统分配的标识提供。
|
type
|
ManagedServiceIdentityType
|
托管服务标识的类型(其中允许 SystemAssigned 和 UserAssigned 类型)。
|
userAssignedIdentities
|
<string,
UserAssignedIdentity>
|
User-Assigned 标识
与资源关联的用户分配标识集。 userAssignedIdentities 字典密钥将为 ARM 资源 ID,格式为“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}”。 字典值可以是请求中的空对象({})。
|
ManagedServiceIdentityType
枚举
托管服务标识的类型(其中允许 SystemAssigned 和 UserAssigned 类型)。
值 |
说明 |
None
|
|
SystemAssigned
|
|
SystemAssigned, UserAssigned
|
|
UserAssigned
|
|
PrivateEndpoint
Object
专用终结点资源。
名称 |
类型 |
说明 |
id
|
string
|
专用终结点的 ARM 标识符
|
PrivateEndpointConnection
Object
专用终结点连接资源。
名称 |
类型 |
说明 |
id
|
string
|
资源的完全限定资源 ID。 Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
name
|
string
|
资源的名称
|
properties.privateEndpoint
|
PrivateEndpoint
|
专用终结点的资源。
|
properties.privateLinkServiceConnectionState
|
PrivateLinkServiceConnectionState
|
有关服务使用者与提供程序之间的连接状态的信息集合。
|
properties.provisioningState
|
PrivateEndpointConnectionProvisioningState
|
专用终结点连接资源的预配状态。
|
type
|
string
|
资源的类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
PrivateEndpointConnectionProvisioningState
枚举
当前预配状态。
值 |
说明 |
Creating
|
|
Deleting
|
|
Failed
|
|
Succeeded
|
|
PrivateEndpointServiceConnectionStatus
枚举
专用终结点连接状态。
值 |
说明 |
Approved
|
|
Pending
|
|
Rejected
|
|
PrivateLinkServiceConnectionState
Object
有关服务使用者与提供程序之间的连接状态的信息集合。
ProvisioningState
枚举
Redis 实例预配状态。
值 |
说明 |
ConfiguringAAD
|
|
Creating
|
|
Deleting
|
|
Disabled
|
|
Failed
|
|
Linking
|
|
Provisioning
|
|
RecoveringScaleFailure
|
|
Scaling
|
|
Succeeded
|
|
Unlinking
|
|
Unprovisioning
|
|
Updating
|
|
PublicNetworkAccess
枚举
是否允许对此缓存使用公共终结点访问。 值是可选的,但如果传入,则必须为“Enabled”或“Disabled”。 如果为“Disabled”,则专用终结点是独占访问方法。 默认值为“Enabled”
RedisAccessKeys
Object
Redis 缓存访问密钥。
名称 |
类型 |
说明 |
primaryKey
|
string
|
客户端可用于通过 Redis 缓存进行身份验证的当前主密钥。
|
secondaryKey
|
string
|
客户端可用于对 Redis 缓存进行身份验证的当前辅助密钥。
|
RedisConfiguration
Object
所有 Redis 设置。 很少有可能的密钥: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 等。
名称 |
类型 |
说明 |
aad-enabled
|
string
|
指定是否已为缓存启用或禁用基于 AAD 的身份验证
|
aof-backup-enabled
|
string
|
指定是否启用 aof 备份
|
aof-storage-connection-string-0
|
string
|
第一个存储帐户连接字符串
|
aof-storage-connection-string-1
|
string
|
第二个存储帐户连接字符串
|
authnotrequired
|
string
|
指定是否禁用身份验证。 强烈建议不要从安全角度设置此属性。
|
maxclients
|
string
|
最大客户端配置
|
maxfragmentationmemory-reserved
|
string
|
每个分片的碎片保留的以兆字节为单位的值
|
maxmemory-delta
|
string
|
为每个分片保留的非缓存使用量(例如故障转移)的值(以兆字节为单位)。
|
maxmemory-policy
|
string
|
当数据不符合其内存限制时使用的逐出策略。
|
maxmemory-reserved
|
string
|
为每个分片保留的非缓存使用量(例如故障转移)的值(以兆字节为单位)。
|
notify-keyspace-events
|
string
|
应监视的键空间事件。
|
preferred-data-archive-auth-method
|
string
|
用于与用于数据存档的存储帐户通信的首选身份验证方法,指定 SAS 或 ManagedIdentity,默认值为 SAS
|
preferred-data-persistence-auth-method
|
string
|
首选身份验证方法,用于与用于数据暂留的存储帐户通信,指定 SAS 或 ManagedIdentity,默认值为 SAS
|
rdb-backup-enabled
|
string
|
指定是否启用 rdb 备份
|
rdb-backup-frequency
|
string
|
指定创建 rdb 备份的频率(以分钟为单位)。 有效值:(15、30、60、360、720、1440)
|
rdb-backup-max-snapshot-count
|
string
|
指定 rdb 备份的最大快照数
|
rdb-storage-connection-string
|
string
|
用于存储 rdb 文件的存储帐户连接字符串
|
storage-subscription-id
|
string
|
使用 ManagedIdentity 的存储帐户的 SubscriptionId(aof/rdb)。
|
zonal-configuration
|
string
|
区域配置
|
RedisCreateParameters
Object
提供给 Create Redis 操作的参数。
名称 |
类型 |
默认值 |
说明 |
identity
|
ManagedServiceIdentity
|
|
资源的标识。
|
location
|
string
|
|
资源所在的地理位置
|
properties.disableAccessKeyAuthentication
|
boolean
|
False
|
如果设置为 true,则会禁用通过访问密钥向 Redis 进行身份验证。 默认值为 false。
|
properties.enableNonSslPort
|
boolean
|
False
|
指定是否启用非 ssl Redis 服务器端口(6379)。
|
properties.minimumTlsVersion
|
TlsVersion
|
|
可选:要求客户端使用指定的 TLS 版本(或更高版本)进行连接(例如,“1.0”、“1.1”、“1.2”)
|
properties.publicNetworkAccess
|
PublicNetworkAccess
|
Enabled
|
是否允许对此缓存使用公共终结点访问。 值是可选的,但如果传入,则必须为“Enabled”或“Disabled”。 如果为“Disabled”,则专用终结点是独占访问方法。 默认值为“Enabled”
|
properties.redisConfiguration
|
RedisConfiguration
|
|
所有 Redis 设置。 很少有可能的密钥: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 等。
|
properties.redisVersion
|
string
|
|
Redis 版本。 这应采用“major[.minor]”(仅需要“major”)或值“latest”,该值引用可用的最新稳定 Redis 版本。 支持的版本:4.0、6.0(最新版)。 默认值为“latest”。
|
properties.replicasPerMaster
|
integer
(int32)
|
|
要为每个主要副本创建的副本数。
|
properties.replicasPerPrimary
|
integer
(int32)
|
|
要为每个主要副本创建的副本数。
|
properties.shardCount
|
integer
(int32)
|
|
在高级群集缓存上创建的分片数。
|
properties.sku
|
Sku
|
|
要部署的 Redis 缓存的 SKU。
|
properties.staticIP
|
string
pattern: ^\d+\.\d+\.\d+\.\d+$
|
|
静态 IP 地址。 (可选)在现有 Azure 虚拟网络中部署 Redis 缓存时可以指定;默认情况下自动分配。
|
properties.subnetId
|
string
pattern: ^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$
|
|
要在其中部署 Redis 缓存的虚拟网络中子网的完整资源 ID。 示例格式:/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Microsoft。{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1
|
properties.tenantSettings
|
object
|
|
租户设置字典
|
properties.updateChannel
|
UpdateChannel
|
|
可选:指定 Redis 缓存将接收的每月 Redis 更新的更新通道。 使用“预览”更新通道的缓存在“稳定”通道缓存之前至少提前 4 周获取最新的 Redis 更新。 默认值为“Stable”。
|
properties.zonalAllocationPolicy
|
ZonalAllocationPolicy
|
|
可选:指定如何将可用性区域分配给 Redis 缓存。 “自动”启用区域冗余,Azure 将根据区域可用性和容量自动选择区域。 “UserDefined”将使用“zone”参数选择传入的可用性区域。 “NoZones”将生成非区域性缓存。 如果未传递“zonalAllocationPolicy”,则会在传入区域时将其设置为“UserDefined”,否则,在不支持区域的区域中,将设置为“自动”,在不支持区域的区域中将其设置为“NoZones”。
|
tags
|
object
|
|
资源标记。
|
zones
|
string[]
|
|
一个可用性区域列表,表示资源需要来自何处。
|
RedisInstanceDetails
Object
redis 单个实例的详细信息。
名称 |
类型 |
说明 |
isMaster
|
boolean
|
指定实例是否为主节点。
|
isPrimary
|
boolean
|
指定实例是否为主节点。
|
nonSslPort
|
integer
(int32)
|
如果 enableNonSslPort 为 true,请提供 Redis 实例非 SSL 端口。
|
shardId
|
integer
(int32)
|
如果启用了群集,则 Redis 实例的分片 ID
|
sslPort
|
integer
(int32)
|
Redis 实例 SSL 端口。
|
zone
|
string
|
如果缓存使用可用性区域,则指定此实例所在的可用性区域。
|
RedisLinkedServer
Object
链接服务器 ID
名称 |
类型 |
说明 |
id
|
string
|
链接服务器 ID。
|
RedisResource
Object
列表或获取操作中的单个 Redis 项。
名称 |
类型 |
默认值 |
说明 |
disableAccessKeyAuthentication
|
boolean
|
False
|
如果设置为 true,则会禁用通过访问密钥向 Redis 进行身份验证。 默认值为 false。
|
enableNonSslPort
|
boolean
|
False
|
指定是否启用非 ssl Redis 服务器端口(6379)。
|
id
|
string
|
|
资源的完全限定资源 ID。 Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
identity
|
ManagedServiceIdentity
|
|
资源的标识。
|
location
|
string
|
|
资源所在的地理位置
|
minimumTlsVersion
|
TlsVersion
|
|
可选:要求客户端使用指定的 TLS 版本(或更高版本)进行连接(例如,“1.0”、“1.1”、“1.2”)
|
name
|
string
|
|
资源的名称
|
properties.accessKeys
|
RedisAccessKeys
|
|
Redis 缓存的键 - 如果此对象不是创建或更新 redis 缓存的响应,则不设置
|
properties.hostName
|
string
|
|
Redis 主机名。
|
properties.instances
|
RedisInstanceDetails[]
|
|
与缓存关联的 Redis 实例列表
|
properties.linkedServers
|
RedisLinkedServer[]
|
|
与缓存关联的链接服务器列表
|
properties.port
|
integer
(int32)
|
|
Redis 非 SSL 端口。
|
properties.privateEndpointConnections
|
PrivateEndpointConnection[]
|
|
与指定的 redis 缓存关联的专用终结点连接列表
|
properties.provisioningState
|
ProvisioningState
|
|
Redis 实例预配状态。
|
properties.sku
|
Sku
|
|
要部署的 Redis 缓存的 SKU。
|
properties.sslPort
|
integer
(int32)
|
|
Redis SSL 端口。
|
properties.staticIP
|
string
pattern: ^\d+\.\d+\.\d+\.\d+$
|
|
静态 IP 地址。 (可选)在现有 Azure 虚拟网络中部署 Redis 缓存时可以指定;默认情况下自动分配。
|
properties.subnetId
|
string
pattern: ^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$
|
|
要在其中部署 Redis 缓存的虚拟网络中子网的完整资源 ID。 示例格式:/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Microsoft。{Network|ClassicNetwork}/VirtualNetworks/vnet1/subnets/subnet1
|
publicNetworkAccess
|
PublicNetworkAccess
|
Enabled
|
是否允许对此缓存使用公共终结点访问。 值是可选的,但如果传入,则必须为“Enabled”或“Disabled”。 如果为“Disabled”,则专用终结点是独占访问方法。 默认值为“Enabled”
|
redisConfiguration
|
RedisConfiguration
|
|
所有 Redis 设置。 很少有可能的密钥: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 等。
|
redisVersion
|
string
|
|
Redis 版本。 这应采用“major[.minor]”(仅需要“major”)或值“latest”,该值引用可用的最新稳定 Redis 版本。 支持的版本:4.0、6.0(最新版)。 默认值为“latest”。
|
replicasPerMaster
|
integer
(int32)
|
|
要为每个主要副本创建的副本数。
|
replicasPerPrimary
|
integer
(int32)
|
|
要为每个主要副本创建的副本数。
|
shardCount
|
integer
(int32)
|
|
在高级群集缓存上创建的分片数。
|
tags
|
object
|
|
资源标记。
|
tenantSettings
|
object
|
|
租户设置字典
|
type
|
string
|
|
资源的类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
updateChannel
|
UpdateChannel
|
|
可选:指定 Redis 缓存将接收的每月 Redis 更新的更新通道。 使用“预览”更新通道的缓存在“稳定”通道缓存之前至少提前 4 周获取最新的 Redis 更新。 默认值为“Stable”。
|
zonalAllocationPolicy
|
ZonalAllocationPolicy
|
|
可选:指定如何将可用性区域分配给 Redis 缓存。 “自动”启用区域冗余,Azure 将根据区域可用性和容量自动选择区域。 “UserDefined”将使用“zone”参数选择传入的可用性区域。 “NoZones”将生成非区域性缓存。 如果未传递“zonalAllocationPolicy”,则会在传入区域时将其设置为“UserDefined”,否则,在不支持区域的区域中,将设置为“自动”,在不支持区域的区域中将其设置为“NoZones”。
|
zones
|
string[]
|
|
一个可用性区域列表,表示资源需要来自何处。
|
Sku
Object
提供给创建 Redis 操作的 SKU 参数。
名称 |
类型 |
说明 |
capacity
|
integer
(int32)
|
要部署的 Redis 缓存的大小。 有效值:对于 C(基本/标准)系列(0、1、2、3、4、5、6)、P(高级)系列(1、2、3、4)。
|
family
|
SkuFamily
|
要使用的 SKU 系列。 有效值:(C、P)。 (C = 基本/标准,P = 高级)。
|
name
|
SkuName
|
要部署的 Redis 缓存的类型。 有效值:(基本、标准、高级)
|
SkuFamily
枚举
要使用的 SKU 系列。 有效值:(C、P)。 (C = 基本/标准,P = 高级)。
SkuName
枚举
要部署的 Redis 缓存的类型。 有效值:(基本、标准、高级)
值 |
说明 |
Basic
|
|
Premium
|
|
Standard
|
|
TlsVersion
枚举
可选:要求客户端使用指定的 TLS 版本(或更高版本)进行连接(例如,“1.0”、“1.1”、“1.2”)
UpdateChannel
枚举
可选:指定 Redis 缓存将接收的每月 Redis 更新的更新通道。 使用“预览”更新通道的缓存在“稳定”通道缓存之前至少提前 4 周获取最新的 Redis 更新。 默认值为“Stable”。
UserAssignedIdentity
Object
用户分配的标识属性
名称 |
类型 |
说明 |
clientId
|
string
(uuid)
|
分配的标识的客户端 ID。
|
principalId
|
string
(uuid)
|
已分配标识的主体 ID。
|
ZonalAllocationPolicy
枚举
可选:指定如何将可用性区域分配给 Redis 缓存。 “自动”启用区域冗余,Azure 将根据区域可用性和容量自动选择区域。 “UserDefined”将使用“zone”参数选择传入的可用性区域。 “NoZones”将生成非区域性缓存。 如果未传递“zonalAllocationPolicy”,则会在传入区域时将其设置为“UserDefined”,否则,在不支持区域的区域中,将设置为“自动”,在不支持区域的区域中将其设置为“NoZones”。
值 |
说明 |
Automatic
|
|
NoZones
|
|
UserDefined
|
|