The az cosmosdb update command that I am using has exceeded length of 8192 characters so I am receiving "The command line is too long." error, the command itself looks following:
az cosmosdb update --resource-group Debug --name firewalldebugdb --ip-range-filter "$dbg1"
$dbg1 is lets say 10000 characters long, how can I solve this problem? Can I somehow pipeline the execution rather than passing the variable or use file write as workaround?
Thanks
az cosmosdb update --ip-range-filter parameter either from file or powershell pipe?
To resolve this issue, you can use a file to store the value of the ip-range-filter
parameter and then pass the file path to the command.
I created text file and stored IP addresses/ranges with comma-separated and without spaces like below:
Sample:
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
Now I used the same command passing the text file in the az cosmosdb update
command.
Command:
az cosmosdb update --resource-group venkatesan-rg --name venkat789 --ip-range-filter @ip_range_filter.txt
Command and output:
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"
}
]
}
Portal:
Reference: