使用 GCP .Net 客户端库创建区域快照

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

我正在通过他们的 .Net 客户端库开发 GCP Google.Cloud.Compute.V1.

我正在使用官方文档中提供的示例使用

SnapshotsClient.InsertAsync
命令创建新快照:

https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1.SnapshotsClient#Google_Cloud_Compute_V1_SnapshotsClient_InsertAsync_System_String_Google_Cloud_Compute_V1_Snapshot_Google_Api_Gax_Grpc_CallSettings_

SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync();
Snapshot snapshotResource = new Snapshot()
{
   Name = "#SNAPSHOT_NAME#",
   SourceDisk = "#SOURCE_DISK#",
};
var response = await snapshotsClient.InsertAsync("#PROJET_ID#", snapshotResource);
var completedResponse = await response.PollUntilCompletedAsync();
Operation result = completedResponse.Result;

效果很好。 我的问题是它创建了多区域快照并将它们放在美国,而我想要的是创建区域快照(例如在 us-central1 下)。

我在Snapshot模型中看到的唯一相关属性是StorageLocations,并且文档没有像其他属性那样声明它是

[Output Only]
,但是当我尝试为其分配新值时我得到:

Property or indexer 'Snapshot.StorageLocations' cannot be assigned to -- it is read only

你能帮我了解如何使用这个库创建区域快照吗?

c# google-cloud-platform snapshot google-cloud-compute-engine
© www.soinside.com 2019 - 2024. All rights reserved.