مشاركة عبر


إدارة Azure Cosmos DB لموارد Gremlin باستخدام قوالب Azure Resource Manager

ينطبق على: العفريت

في هذه المقالة، ستتعلم كيفية استخدام قوالب Azure Resource Manager للمساعدة في نشر وإدارة حسابات وقواعد بيانات والرسومات البيانية لـ Azure Cosmos DB.

تحتوي هذه المقالة على أمثلة لواجهة برمجة التطبيقات لحسابات Gremlin فقط، للعثور على أمثلة لحسابات نوع واجهة برمجة التطبيقات الأخرى، راجع: استخدام قوالب Azure Resource Manager مع واجهة برمجة تطبيقات Azure Cosmos DB لمقالات Cassandra و NoSQL و MongoDB و Table.

هام

  • تقتصر أسماء الحسابات على 44 حرفًا، وكلها بأحرف إنجليزية صغيرة.
  • لتغيير قيم معدل النقل، أعد توزيع القالب باستخدام RU/s المحدثة.
  • عند إضافة مواقع أو إزالتها إلى حساب Azure Cosmos DB، لا يمكنك تعديل خصائص أخرى في نفس الوقت. تتم هذه العمليات بشكل منفصل.

لإنشاء أي من موارد Azure Cosmos DB أدناه، انسخ قالب المثال التالي إلى ملف json جديد. يمكنك إنشاء ملف json للمعلمات اختيارياً لاستخدامه عند توزيع مثيلات متعددة لنفس المورد بأسماء وقيم مختلفة. هناك العديد من الطرق لنشر قوالب Azure Resource Manager بما في ذلك، مدخل Microsoft Azure وAzure CLI وAzure PowerShell وGitHub.

حساب Azure Cosmos DB لـ Gremlin بمعدل نقل مزود بالتحجيم التلقائي

سيقوم هذا القالب بإنشاء حساب Azure Cosmos DB لواجهة برمجة التطبيقات ل Gremlin مع قاعدة بيانات ورسم بياني مع معدل نقل التحجيم التلقائي. يتوفر هذا القالب أيضاً للتوزيع بنقرة واحدة من معرض قوالب Azure Quickstart.

زر لنشر قالب Resource Manager إلى Azure.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.8.9.13224",
      "templateHash": "18150046024853886723"
    }
  },
  "parameters": {
    "accountName": {
      "type": "string",
      "defaultValue": "[format('gremlin-{0}', uniqueString(resourceGroup().id))]",
      "metadata": {
        "description": "Cosmos DB account name"
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for the Cosmos DB account."
      }
    },
    "primaryRegion": {
      "type": "string",
      "metadata": {
        "description": "The primary replica region for the Cosmos DB account."
      }
    },
    "secondaryRegion": {
      "type": "string",
      "metadata": {
        "description": "The secondary replica region for the Cosmos DB account."
      }
    },
    "defaultConsistencyLevel": {
      "type": "string",
      "defaultValue": "Session",
      "allowedValues": [
        "Eventual",
        "ConsistentPrefix",
        "Session",
        "BoundedStaleness",
        "Strong"
      ],
      "metadata": {
        "description": "The default consistency level of the Cosmos DB account."
      }
    },
    "maxStalenessPrefix": {
      "type": "int",
      "defaultValue": 100000,
      "maxValue": 2147483647,
      "minValue": 10,
      "metadata": {
        "description": "Max stale requests. Required for BoundedStaleness. Valid ranges, Single Region: 10 to 2147483647. Multi Region: 100000 to 2147483647."
      }
    },
    "maxIntervalInSeconds": {
      "type": "int",
      "defaultValue": 300,
      "maxValue": 86400,
      "minValue": 5,
      "metadata": {
        "description": "Max lag time (seconds). Required for BoundedStaleness. Valid ranges, Single Region: 5 to 84600. Multi Region: 300 to 86400."
      }
    },
    "systemManagedFailover": {
      "type": "bool",
      "defaultValue": true,
      "metadata": {
        "description": "Enable system managed failover for regions"
      }
    },
    "databaseName": {
      "type": "string",
      "metadata": {
        "description": "The name for the Gremlin database"
      }
    },
    "graphName": {
      "type": "string",
      "metadata": {
        "description": "The name for the Gremlin graph"
      }
    },
    "autoscaleMaxThroughput": {
      "type": "int",
      "defaultValue": 1000,
      "maxValue": 1000000,
      "minValue": 1000,
      "metadata": {
        "description": "Maximum autoscale throughput for the graph"
      }
    }
  },
  "variables": {
    "consistencyPolicy": {
      "Eventual": {
        "defaultConsistencyLevel": "Eventual"
      },
      "ConsistentPrefix": {
        "defaultConsistencyLevel": "ConsistentPrefix"
      },
      "Session": {
        "defaultConsistencyLevel": "Session"
      },
      "BoundedStaleness": {
        "defaultConsistencyLevel": "BoundedStaleness",
        "maxStalenessPrefix": "[parameters('maxStalenessPrefix')]",
        "maxIntervalInSeconds": "[parameters('maxIntervalInSeconds')]"
      },
      "Strong": {
        "defaultConsistencyLevel": "Strong"
      }
    },
    "locations": [
      {
        "locationName": "[parameters('primaryRegion')]",
        "failoverPriority": 0,
        "isZoneRedundant": false
      },
      {
        "locationName": "[parameters('secondaryRegion')]",
        "failoverPriority": 1,
        "isZoneRedundant": false
      }
    ]
  },
  "resources": [
    {
      "type": "Microsoft.DocumentDB/databaseAccounts",
      "apiVersion": "2022-05-15",
      "name": "[toLower(parameters('accountName'))]",
      "location": "[parameters('location')]",
      "kind": "GlobalDocumentDB",
      "properties": {
        "capabilities": [
          {
            "name": "EnableGremlin"
          }
        ],
        "consistencyPolicy": "[variables('consistencyPolicy')[parameters('defaultConsistencyLevel')]]",
        "locations": "[variables('locations')]",
        "databaseAccountOfferType": "Standard",
        "enableAutomaticFailover": "[parameters('systemManagedFailover')]"
      }
    },
    {
      "type": "Microsoft.DocumentDB/databaseAccounts/gremlinDatabases",
      "apiVersion": "2022-05-15",
      "name": "[format('{0}/{1}', toLower(parameters('accountName')), parameters('databaseName'))]",
      "properties": {
        "resource": {
          "id": "[parameters('databaseName')]"
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.DocumentDB/databaseAccounts', toLower(parameters('accountName')))]"
      ]
    },
    {
      "type": "Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs",
      "apiVersion": "2022-05-15",
      "name": "[format('{0}/{1}', format('{0}/{1}', toLower(parameters('accountName')), parameters('databaseName')), parameters('graphName'))]",
      "properties": {
        "resource": {
          "id": "[parameters('graphName')]",
          "indexingPolicy": {
            "indexingMode": "consistent",
            "includedPaths": [
              {
                "path": "/*"
              }
            ],
            "excludedPaths": [
              {
                "path": "/myPathToNotIndex/*"
              }
            ]
          },
          "partitionKey": {
            "paths": [
              "/myPartitionKey"
            ],
            "kind": "Hash"
          }
        },
        "options": {
          "autoscaleSettings": {
            "maxThroughput": "[parameters('autoscaleMaxThroughput')]"
          }
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.DocumentDB/databaseAccounts/gremlinDatabases', split(format('{0}/{1}', toLower(parameters('accountName')), parameters('databaseName')), '/')[0], split(format('{0}/{1}', toLower(parameters('accountName')), parameters('databaseName')), '/')[1])]"
      ]
    }
  ]
}

الخطوات التالية

فيما يأتي بعض الموارد الإضافية: