-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
63 lines (52 loc) · 1.98 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Tea;
using Tea.Utils;
namespace AliyunSpotPriceHistoryQuery
{
public class Sample
{
/**
* 使用 AK & SK 初始化账号 Client
* @param accessKeyId
* @param accessKeySecret
* @return Client
* @throws Exception
*/
public static AlibabaCloud.SDK.Ecs20140526.Client CreateClient(string accessKeyId, string accessKeySecret)
{
AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
{
// 自己的 AccessKey ID
AccessKeyId = accessKeyId,
// 自己的 AccessKey Secret
AccessKeySecret = accessKeySecret,
};
// 访问的域名
config.Endpoint = "ecs.cn-chengdu.aliyuncs.com";
return new AlibabaCloud.SDK.Ecs20140526.Client(config);
}
public static void Main(string[] args)
{
var config = new ConfigurationBuilder().AddUserSecrets<Sample>().Build();
AlibabaCloud.SDK.Ecs20140526.Client client = CreateClient(config["Aliyun:AccessKeyId"], config["Aliyun:AccessKeySecret"]);
AlibabaCloud.SDK.Ecs20140526.Models.DescribeSpotPriceHistoryRequest describeSpotPriceHistoryRequest = new AlibabaCloud.SDK.Ecs20140526.Models.DescribeSpotPriceHistoryRequest
{
RegionId = "cn-chengdu",
NetworkType = "vpc",
InstanceType = "ecs.c6e.xlarge",
StartTime = "2022-01-01T00:00:00Z",
};
var res = client.DescribeSpotPriceHistory(describeSpotPriceHistoryRequest);
foreach (var s in res.Body.SpotPrices.SpotPriceType)
{
Console.WriteLine(s.SpotPrice);
}
}
}
}