-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Expand file tree
/
Copy pathSample_AppCertificateResource.cs
More file actions
141 lines (118 loc) · 7.9 KB
/
Sample_AppCertificateResource.cs
File metadata and controls
141 lines (118 loc) · 7.9 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.AppService.Models;
using Azure.ResourceManager.Resources;
using NUnit.Framework;
namespace Azure.ResourceManager.AppService.Samples
{
public partial class Sample_AppCertificateResource
{
[Test]
[Ignore("Only validating compilation of examples")]
public async Task GetAppCertificates_ListCertificatesForSubscription()
{
// Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListCertificates.json
// this example is just showing the usage of "Certificates_List" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SubscriptionResource created on azure
// for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource
string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// invoke the operation and iterate over the result
await foreach (AppCertificateResource item in subscriptionResource.GetAppCertificatesAsync())
{
// the variable item is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
AppCertificateData resourceData = item.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
Console.WriteLine("Succeeded");
}
[Test]
[Ignore("Only validating compilation of examples")]
public async Task Get_GetCertificate()
{
// Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetCertificate.json
// this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this AppCertificateResource created on azure
// for more information of creating AppCertificateResource, please refer to the document of AppCertificateResource
string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
string resourceGroupName = "testrg123";
string name = "testc6282";
ResourceIdentifier appCertificateResourceId = AppCertificateResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name);
AppCertificateResource appCertificate = client.GetAppCertificateResource(appCertificateResourceId);
// invoke the operation
AppCertificateResource result = await appCertificate.GetAsync();
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
AppCertificateData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
[Test]
[Ignore("Only validating compilation of examples")]
public async Task Delete_DeleteCertificate()
{
// Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DeleteCertificate.json
// this example is just showing the usage of "Certificates_Delete" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this AppCertificateResource created on azure
// for more information of creating AppCertificateResource, please refer to the document of AppCertificateResource
string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
string resourceGroupName = "testrg123";
string name = "testc6282";
ResourceIdentifier appCertificateResourceId = AppCertificateResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name);
AppCertificateResource appCertificate = client.GetAppCertificateResource(appCertificateResourceId);
// invoke the operation
await appCertificate.DeleteAsync(WaitUntil.Completed);
Console.WriteLine("Succeeded");
}
[Test]
[Ignore("Only validating compilation of examples")]
public async Task Update_PatchCertificate()
{
// Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/PatchCertificate.json
// this example is just showing the usage of "Certificates_Update" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this AppCertificateResource created on azure
// for more information of creating AppCertificateResource, please refer to the document of AppCertificateResource
string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345";
string resourceGroupName = "testrg123";
string name = "testc6282";
ResourceIdentifier appCertificateResourceId = AppCertificateResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name);
AppCertificateResource appCertificate = client.GetAppCertificateResource(appCertificateResourceId);
// invoke the operation
AppCertificatePatch patch = new AppCertificatePatch()
{
Password = "<password>",
};
AppCertificateResource result = await appCertificate.UpdateAsync(patch);
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
AppCertificateData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
}
}