admin管理员组文章数量:1279085
I am trying to write a script to automate the process for restoring an Azure AKS cluster to the latest backup using AZ CLI. I am using this documentation, as my guide. However, I am running into a problem with the second step of the Prepare the restore request process where we execute the az dataprotection backup-instance restore initialize-for-item-recovery command. I get this output:
ERROR: (InvalidApiVersionParameter) The api-version '2024-04-01' is invalid. The
supported versions are '2024-11-01,2024-08-01,2024-07-01,2024-06-01-preview,2024-03-
01,2023-07-01,2023-07-01-preview,2023-03-01-preview,2022-12-01,2022-11-01-preview,2022-
09-01,2022-06-01,2022-05-01,2022-03-01-preview,2022-01-01,2021-04-01,2021-01-01,2020-
10-01,2020-09-01,2020-08-01,2020-07-01,2020-06-01,2020-05-01,2020-01-01,2019-11-
01,2019-10-01,2019-09-01,2019-08-01,2019-07-01,2019-06-01,2019-05-10,2019-05-01,2019-
03-01,2018-11-01,2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-
01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-
09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-
04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'.
Code: InvalidApiVersionParameter
Message: The api-version '2024-04-01' is invalid. The supported versions are '2024-11-
01,2024-08-01,2024-07-01,2024-06-01-preview,2024-03-01,2023-07-01,2023-07-01-
preview,2023-03-01-preview,2022-12-01,2022-11-01-preview,2022-09-01,2022-06-01,2022-05-
01,2022-03-01-preview,2022-01-01,2021-04-01,2021-01-01,2020-10-01,2020-09-01,2020-08-
01,2020-07-01,2020-06-01,2020-05-01,2020-01-01,2019-11-01,2019-10-01,2019-09-01,2019-
08-01,2019-07-01,2019-06-01,2019-05-10,2019-05-01,2019-03-01,2018-11-01,2018-09-
01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-
08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-
01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-
01,2014-02-26,2014-04'.: {"error":{"code":"InvalidApiVersionParameter","message":"The
api-version '2024-04-01' is invalid. The supported versions are '2024-11-01,2024-08-
01,2024-07-01,2024-06-01-preview,2024-03-01,2023-07-01,2023-07-01-preview,2023-03-01-
preview,2022-12-01,2022-11-01-preview,2022-09-01,2022-06-01,2022-05-01,2022-03-01-
preview,2022-01-01,2021-04-01,2021-01-01,2020-10-01,2020-09-01,2020-08-01,2020-07-
01,2020-06-01,2020-05-01,2020-01-01,2019-11-01,2019-10-01,2019-09-01,2019-08-01,2019-
07-01,2019-06-01,2019-05-10,2019-05-01,2019-03-01,2018-11-01,2018-09-01,2018-08-
01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-08-01,2017-
06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-
01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-
26,2014-04'."}}
From what I understand, this is a problem with the AZ CLI version and it needs to be updated to the latest version. Despite that, adding az upgrade to my bash script doesn't help.
clusterName=$AKS_CLUSTER_NAME
subscriptionId=$SUBSCRIPTION_ID
backupVault=$BVAULT
rgName=$RGNAME
region="westus"
az upgrade
# Write the restore configuration to a JSON file
restoreConfig=$(jq -n --argjson config '{
conflict_policy: "Skip",
excluded_namespaces: null,
excluded_resource_types: null,
include_cluster_scope_resources: true,
included_namespaces: null,
included_resource_types: null,
label_selectors: null,
namespace_mappings: null,
object_type: "KubernetesClusterRestoreCriteria",
persistent_volume_restore_mode: "RestoreWithVolumeData",
resource_modifier_reference: null,
restore_hook_references: null,
staging_resource_group_id: null,
staging_storage_account_id: null
}' '$config')
if echo $restoreConfig | jq . > restoreconfig.json; then
echo "Restore configuration written to restoreconfig.json successfully."
else
echo "Failed to write restore configuration to restoreconfig.json."
exit 1
fi
# Get JSON output
jsonOutput=$(az dataprotection backup-instance list-from-resourcegraph --datasource-type "AzureKubernetesService" --datasource-id "/subscriptions/$subscriptionId/resourceGroups/$rgName/providers/Microsoft.ContainerService/managedClusters/$clusterName")
# Parse JSON and extract the latest instance name
latestInstanceName=$(echo $jsonOutput | jq -r '.[0].name')
# Print the latest instance name
echo "Latest instance name: $latestInstanceName"
# Get the list of recovery points for the latest instance
recoveryPointsJson=$(az dataprotection recovery-point list --backup-instance-name $latestInstanceName --resource-group $rgName --vault-name $backupVault)
# Parse JSON and extract the latest recovery point details
latestRecoveryPoint=$(echo $recoveryPointsJson | jq -r 'sort_by(.properties.recoveryPointTime) | last')
# Extract the name and creation time of the latest recovery point
recoveryPointName=$(echo $latestRecoveryPoint | jq -r '.name')
recoveryPointCreationTime=$(echo $latestRecoveryPoint | jq -r '.properties.recoveryPointTime')
recoveryPointID=$(echo $latestRecoveryPoint | jq -r '.id')
# Print the latest recovery point details
echo "Latest recovery point name: $recoveryPointName"
echo "Latest recovery point creation time: $recoveryPointCreationTime"
echo "Latest recovery point ID: $recoveryPointID"
backupInstanceID="/subscriptions/$subscriptionId/resourceGroups/$rgName/providers/Microsoft.DataProtection/backupVaults/$backupVault/backupInstances/$latestInstanceName"
echo "Backup Instance ID: $backupInstanceID"
# Initialize restore configuration
if az dataprotection backup-instance initialize-restoreconfig --datasource-type AzureKubernetesService > restoreconfig.json; then
echo "Restore configuration initialized successfully."
else
echo "Failed to initialize restore configuration."
exit 1
fi
# Initialize item recovery
if az dataprotection backup-instance restore initialize-for-item-recovery --datasource-type AzureKubernetesService --restore-location $region --source-datastore OperationalStore --recovery-point-id $recoveryPointID --backup-instance-id $backupInstanceID --restore-configuration restoreconfig.json > restorerequestobject.json; then
echo "Item recovery initialized successfully."
else
echo "Failed to initialize item recovery."
exit 1
fi
From what I read online, adding other parameters to the command like --resource-group to fix the problem, but the documentation of this command doesn't have this option. Does anyone have a suggestion on how to fix this CLI API issue?
I am trying to write a script to automate the process for restoring an Azure AKS cluster to the latest backup using AZ CLI. I am using this documentation, as my guide. However, I am running into a problem with the second step of the Prepare the restore request process where we execute the az dataprotection backup-instance restore initialize-for-item-recovery command. I get this output:
ERROR: (InvalidApiVersionParameter) The api-version '2024-04-01' is invalid. The
supported versions are '2024-11-01,2024-08-01,2024-07-01,2024-06-01-preview,2024-03-
01,2023-07-01,2023-07-01-preview,2023-03-01-preview,2022-12-01,2022-11-01-preview,2022-
09-01,2022-06-01,2022-05-01,2022-03-01-preview,2022-01-01,2021-04-01,2021-01-01,2020-
10-01,2020-09-01,2020-08-01,2020-07-01,2020-06-01,2020-05-01,2020-01-01,2019-11-
01,2019-10-01,2019-09-01,2019-08-01,2019-07-01,2019-06-01,2019-05-10,2019-05-01,2019-
03-01,2018-11-01,2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-
01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-
09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-
04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'.
Code: InvalidApiVersionParameter
Message: The api-version '2024-04-01' is invalid. The supported versions are '2024-11-
01,2024-08-01,2024-07-01,2024-06-01-preview,2024-03-01,2023-07-01,2023-07-01-
preview,2023-03-01-preview,2022-12-01,2022-11-01-preview,2022-09-01,2022-06-01,2022-05-
01,2022-03-01-preview,2022-01-01,2021-04-01,2021-01-01,2020-10-01,2020-09-01,2020-08-
01,2020-07-01,2020-06-01,2020-05-01,2020-01-01,2019-11-01,2019-10-01,2019-09-01,2019-
08-01,2019-07-01,2019-06-01,2019-05-10,2019-05-01,2019-03-01,2018-11-01,2018-09-
01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-
08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-
01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-
01,2014-02-26,2014-04'.: {"error":{"code":"InvalidApiVersionParameter","message":"The
api-version '2024-04-01' is invalid. The supported versions are '2024-11-01,2024-08-
01,2024-07-01,2024-06-01-preview,2024-03-01,2023-07-01,2023-07-01-preview,2023-03-01-
preview,2022-12-01,2022-11-01-preview,2022-09-01,2022-06-01,2022-05-01,2022-03-01-
preview,2022-01-01,2021-04-01,2021-01-01,2020-10-01,2020-09-01,2020-08-01,2020-07-
01,2020-06-01,2020-05-01,2020-01-01,2019-11-01,2019-10-01,2019-09-01,2019-08-01,2019-
07-01,2019-06-01,2019-05-10,2019-05-01,2019-03-01,2018-11-01,2018-09-01,2018-08-
01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-08-01,2017-
06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-
01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-
26,2014-04'."}}
From what I understand, this is a problem with the AZ CLI version and it needs to be updated to the latest version. Despite that, adding az upgrade to my bash script doesn't help.
clusterName=$AKS_CLUSTER_NAME
subscriptionId=$SUBSCRIPTION_ID
backupVault=$BVAULT
rgName=$RGNAME
region="westus"
az upgrade
# Write the restore configuration to a JSON file
restoreConfig=$(jq -n --argjson config '{
conflict_policy: "Skip",
excluded_namespaces: null,
excluded_resource_types: null,
include_cluster_scope_resources: true,
included_namespaces: null,
included_resource_types: null,
label_selectors: null,
namespace_mappings: null,
object_type: "KubernetesClusterRestoreCriteria",
persistent_volume_restore_mode: "RestoreWithVolumeData",
resource_modifier_reference: null,
restore_hook_references: null,
staging_resource_group_id: null,
staging_storage_account_id: null
}' '$config')
if echo $restoreConfig | jq . > restoreconfig.json; then
echo "Restore configuration written to restoreconfig.json successfully."
else
echo "Failed to write restore configuration to restoreconfig.json."
exit 1
fi
# Get JSON output
jsonOutput=$(az dataprotection backup-instance list-from-resourcegraph --datasource-type "AzureKubernetesService" --datasource-id "/subscriptions/$subscriptionId/resourceGroups/$rgName/providers/Microsoft.ContainerService/managedClusters/$clusterName")
# Parse JSON and extract the latest instance name
latestInstanceName=$(echo $jsonOutput | jq -r '.[0].name')
# Print the latest instance name
echo "Latest instance name: $latestInstanceName"
# Get the list of recovery points for the latest instance
recoveryPointsJson=$(az dataprotection recovery-point list --backup-instance-name $latestInstanceName --resource-group $rgName --vault-name $backupVault)
# Parse JSON and extract the latest recovery point details
latestRecoveryPoint=$(echo $recoveryPointsJson | jq -r 'sort_by(.properties.recoveryPointTime) | last')
# Extract the name and creation time of the latest recovery point
recoveryPointName=$(echo $latestRecoveryPoint | jq -r '.name')
recoveryPointCreationTime=$(echo $latestRecoveryPoint | jq -r '.properties.recoveryPointTime')
recoveryPointID=$(echo $latestRecoveryPoint | jq -r '.id')
# Print the latest recovery point details
echo "Latest recovery point name: $recoveryPointName"
echo "Latest recovery point creation time: $recoveryPointCreationTime"
echo "Latest recovery point ID: $recoveryPointID"
backupInstanceID="/subscriptions/$subscriptionId/resourceGroups/$rgName/providers/Microsoft.DataProtection/backupVaults/$backupVault/backupInstances/$latestInstanceName"
echo "Backup Instance ID: $backupInstanceID"
# Initialize restore configuration
if az dataprotection backup-instance initialize-restoreconfig --datasource-type AzureKubernetesService > restoreconfig.json; then
echo "Restore configuration initialized successfully."
else
echo "Failed to initialize restore configuration."
exit 1
fi
# Initialize item recovery
if az dataprotection backup-instance restore initialize-for-item-recovery --datasource-type AzureKubernetesService --restore-location $region --source-datastore OperationalStore --recovery-point-id $recoveryPointID --backup-instance-id $backupInstanceID --restore-configuration restoreconfig.json > restorerequestobject.json; then
echo "Item recovery initialized successfully."
else
echo "Failed to initialize item recovery."
exit 1
fi
From what I read online, adding other parameters to the command like --resource-group to fix the problem, but the documentation of this command doesn't have this option. Does anyone have a suggestion on how to fix this CLI API issue?
Share Improve this question asked Feb 24 at 18:06 Devin York DJDevin York DJ 556 bronze badges1 Answer
Reset to default 0The image I was running this script on was not up to date on the latest version of ubuntu. Switching to that fixed the issue.
版权声明:本文标题:azure - AZ CLI az dataprotection backup-instance restore initialize-for-item-recovery API issue - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741248931a2365426.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论