az cosmosdb update --ip-range-filter 来自文件或 powershell 管道的参数

问题描述 投票:0回答:1

我使用的 az cosmosdb update 命令的长度超过了 8192 个字符,因此我收到“命令行太长”。错误,命令本身如下所示:

az cosmosdb update --resource-group Debug --name firewalldebugdb --ip-range-filter "$dbg1"

$dbg1 可以说是 10000 个字符长,我该如何解决这个问题?我可以以某种方式管道执行而不是传递变量或使用文件写入作为解决方法吗?

谢谢

azure powershell azure-cosmosdb
1个回答
0
投票

az cosmosdb update --ip-range-filter 参数来自文件或 powershell 管道?

要解决此问题,您可以使用文件来存储

ip-range-filter
参数的值,然后将文件路径传递给命令。

我创建了文本文件并存储了用逗号分隔且不带空格的 IP 地址/范围,如下所示:

样品:

1.0.0.1,1.0.0.2,1.0.0.3,1.0.0.4,1.0.0.5,1.0.0.6,1.0.0.7,1.0.0.8,1.0.0.9,1.0.0.10,1.0.0.11,1.0.0.12,1.0.0.13,1.0.0.14,1.0.0.15,1.0.0.16,1.0.0.17,1.0.0.18,1.0.0.19,1.0.0.20,1.0.0.21,1.0.0.22,1.0.0.23,1.0.0.24,1.0.0.25,1.0.0.26,1.0.0.27,1.0.0.28,1.0.0.29,1.0.0.30,1.0.0.31,1.0.0.32,1.0.0.33,1.0.0.34,1.0.0.35,1.0.0.36,1.0.0.37,1.0.0.38,1.0.0.39,1.0.0.40,1.0.0.41,1.0.0.42,1.0.0.43,1.0.0.44,1.0.0.45,1.0.0.46,1.0.0.47,1.0.0.48,1.0.0.49,1.0.0.50,1.0.0.51,1.0.0.52,1.0.0.53,..........1.0.4.27

现在我使用相同的命令在

az cosmosdb update
命令中传递文本文件。

命令:

az cosmosdb update --resource-group venkatesan-rg --name venkat789 --ip-range-filter @ip_range_filter.txt

命令与输出:

az cosmosdb update --resource-group venkatesan-rg --name venkat789 --ip-range-filter @ip_range_filter.txt

{
"analyticalStorageConfiguration": {
  "schemaType": "WellDefined"
},
"apiProperties": null,
"backupPolicy": {
  "migrationState": null,
  "periodicModeProperties": {
    "backupIntervalInMinutes": 240,
    "backupRetentionIntervalInHours": 8,
    "backupStorageRedundancy": "Geo"
  },
  "type": "Periodic"
},
"capabilities": [],
"capacity": null,
"connectorOffer": null,
"consistencyPolicy": {
  "defaultConsistencyLevel": "Session",
  "maxIntervalInSeconds": 5,
  "maxStalenessPrefix": 100
},
"cors": [],
"createMode": null,
"customerManagedKeyStatus": null,
"databaseAccountOfferType": "Standard",
"defaultIdentity": "FirstPartyIdentity",
"disableKeyBasedMetadataWriteAccess": false,
"disableLocalAuth": false,
"documentEndpoint": "https://vexxx789.documents.azure.com:443/",
"enableAnalyticalStorage": false,
"enableAutomaticFailover": false,
"enableBurstCapacity": false,
"enableCassandraConnector": null,
"enableFreeTier": false,
"enableMultipleWriteLocations": true,
"enablePartitionMerge": false,
"failoverPolicies": [
  {
    "failoverPriority": 0,
    "id": "venkat789-centralus",
    "locationName": "Central US"
  },
  {
    "failoverPriority": 1,
    "id": "venkat789-eastus2",
    "locationName": "East US 2"
  }
],
"id": "/subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.DocumentDB/databaseAccounts/venkat789",
"identity": {
  "principalId": null,
  "tenantId": null,
  "type": "None",
  "userAssignedIdentities": null
},
"instanceId": "60xxxfa4",
"ipRules": [
  {
    "ipAddressOrRange": "1.0.4.28"
  }
  {
  "ipAddressOrRange": "1.0.0.1"
  },
 ........
],
"isVirtualNetworkFilterEnabled": false,
"keyVaultKeyUri": null,
"keysMetadata": {
  "primaryMasterKey": {
    "generationTime": "2024-07-29T08:34:17.791792+00:00"
  },
  "primaryReadonlyMasterKey": {
    "generationTime": "2024-07-29T08:34:17.791792+00:00"
  },
  "secondaryMasterKey": {
    "generationTime": "2024-07-29T08:34:17.791792+00:00"
  },
  "secondaryReadonlyMasterKey": {
    "generationTime": "2024-07-29T08:34:17.791792+00:00"
  }
},
"kind": "GlobalDocumentDB",
"location": "Central US",
"locations": [
  {
    "documentEndpoint": "https://venkat789-centralus.documents.azure.com:443/",
    "failoverPriority": 0,
    "id": "venkat789-centralus",
    "isZoneRedundant": false,
    "locationName": "Central US",
    "provisioningState": "Succeeded"
  },
  {
    "documentEndpoint": "https://vexxx789-eastus2.documents.azure.com:443/",
    "failoverPriority": 1,
    "id": "venkat789-eastus2",
    "isZoneRedundant": false,
    "locationName": "East US 2",
    "provisioningState": "Succeeded"
  }
],
"minimalTlsVersion": "Tls12",
"name": "venkat789",
"networkAclBypass": "None",
"networkAclBypassResourceIds": [],
"privateEndpointConnections": null,
"provisioningState": "Succeeded",
"publicNetworkAccess": "Enabled",
"readLocations": [
  {
    "documentEndpoint": "https://venkat789-centralus.documents.azure.com:443/",
    "failoverPriority": 0,
    "id": "venkat789-centralus",
    "isZoneRedundant": false,
    "locationName": "Central US",
    "provisioningState": "Succeeded"
  },
  {
    "documentEndpoint": "https://venkat789-eastus2.documents.azure.com:443/",
    "failoverPriority": 1,
    "id": "venkat789-eastus2",
    "isZoneRedundant": false,
    "locationName": "East US 2",
    "provisioningState": "Succeeded"
  }
],
"resourceGroup": "venkatesan-rg",
"restoreParameters": null,
"systemData": {
  "createdAt": "2024-07-29T08:34:17.791792+00:00",
  "createdBy": null,
  "createdByType": null,
  "lastModifiedAt": null,
  "lastModifiedBy": null,
  "lastModifiedByType": null
},
"tags": {
  "defaultExperience": "Core (SQL)",
  "hidden-cosmos-mmspecial": ""
},
"type": "Microsoft.DocumentDB/databaseAccounts",
"virtualNetworkRules": [],
"writeLocations": [
  {
    "documentEndpoint": "https://venkat789-centralus.documents.azure.com:443/",
    "failoverPriority": 0,
    "id": "venkat789-centralus",
    "isZoneRedundant": false,
    "locationName": "Central US",
    "provisioningState": "Succeeded"
  },
  {
    "documentEndpoint": "https://venkat789-eastus2.documents.azure.com:443/",
    "failoverPriority": 1,
    "id": "venkat789-eastus2",
    "isZoneRedundant": false,
    "locationName": "East US 2",
    "provisioningState": "Succeeded"
  }
]
}

传送门: enter image description here

参考:

az cosmosdb |微软学习

© www.soinside.com 2019 - 2024. All rights reserved.