-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
32 lines (24 loc) · 1.14 KB
/
Program.cs
File metadata and controls
32 lines (24 loc) · 1.14 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
using Azure.Core;
using Azure.Identity;
using System.Net.Http.Headers;
DefaultAzureCredentialOptions DefaultAzureCredentialOptions = new()
{
ExcludeAzureCliCredential = false,
ExcludeVisualStudioCredential = false,
ExcludeAzurePowerShellCredential = false
};
// Fill in specific information here:
string SubscriptionId = "";
string ResourceGroupName = "";
string CapacityName = "";
string CapacityUrl = $"https://management.azure.com/subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Fabric/capacities/{CapacityName}";
var defaultAzureCredential = new DefaultAzureCredential(DefaultAzureCredentialOptions);
string bearerToken = defaultAzureCredential.GetToken(new TokenRequestContext(new[] { "https://management.azure.com" })).Token;
HttpClient client = new();
using (var request = new HttpRequestMessage(HttpMethod.Post, $"{CapacityUrl}/suspend?api-version=2022-07-01-preview"))
{
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken);
var response = client.SendAsync(request);
response.Wait();
Console.WriteLine(response.Result);
}