![]() |
VOOZH | about |
dotnet add package OPS.GoCloud.AzureClient --version 1.1.9
NuGet\Install-Package OPS.GoCloud.AzureClient -Version 1.1.9
<PackageReference Include="OPS.GoCloud.AzureClient" Version="1.1.9" />
<PackageVersion Include="OPS.GoCloud.AzureClient" Version="1.1.9" />Directory.Packages.props
<PackageReference Include="OPS.GoCloud.AzureClient" />Project file
paket add OPS.GoCloud.AzureClient --version 1.1.9
#r "nuget: OPS.GoCloud.AzureClient, 1.1.9"
#:package OPS.GoCloud.AzureClient@1.1.9
#addin nuget:?package=OPS.GoCloud.AzureClient&version=1.1.9Install as a Cake Addin
#tool nuget:?package=OPS.GoCloud.AzureClient&version=1.1.9Install as a Cake Tool
dotnet add package OPS.GoCloud.AzureClient
var tenantId = "YOUR_TENANT_ID";
AzureClient azureClient = new AzureClient(tenantId);
var tenantId = "YOUR_TENANT_ID";
var clientId = "YOUR_CLIENT_ID";
var clientsecret = "YOUR_CLIENT_SECRET";
AzureClient azureClient = new AzureClient(tenantId,clientId,clientsecret);
var tenantId = "YOUR_TENANT_ID";
var umiClientId = "User-Managed Identity_CLIENT_ID";
AzureClient azureClient = new AzureClient(tenantId,umiClientId);
var tenantId = "YOUR_TENANT_ID";
// Use PowerShell or CLI client ID for interactive login
AzureClient azureClient = new AzureClient(tenantId, InteractiveDevice.PowerShell);
// or
AzureClient azureClient = new AzureClient(tenantId, InteractiveDevice.CLI);
var tenantId = "YOUR_TENANT_ID";
var accessToken = "YOUR_ACCESS_TOKEN";
TokenCredential credential = /* your credential */;
AzureClient azureClient = new AzureClient(tenantId, accessToken, credential);
List all the enabled Azure subscriptions in your tenant
var subs = azureClient.ListSubscriptions();
List all the Azure subscriptions in your tenant
var subs = azureClient.ListSubscriptions(enabledOnly: false);
public class subscription : ArmBase<subscription>
{
public string subscriptionId { get; set; }
public string name { get; set; }
}
string query = "resourcecontainers | where type == 'microsoft.resources/subscriptions | project subscriptionId,name";
List<subscription> azureSubs = subscription.Query(azureClient, query);
public class PolicyAssignment
{
public string id { get; set; }
public string name { get; set; }
public string location { get; set; }
public object properties { get; set; }
}
string policyAssignmentId = "";
string uri = $"https://management.azure.com/{policyAssignmentId}?api-version=2021-06-01";
// The returned respose content is data in JSON string
var resultsJson = await azureClient.SendToAzRestAPI(uri,HttpMethod.Get);
PolicyAssignment policyAssignment = JsonConvert.DeserializeObject<PolicyAssignment>(resultsJson);
var graphClientId = "YOUR_CLIENT_ID";
var graphClientsecret = "YOUR_CLIENT_SECRET";
azureClient.InitiateGraphClient(graphClientId,graphClientsecret);
To get a full list of MS Graph objects and optinally parse into your custom class type, we can call the method ListFromMsGraph.
public class MyUsersContainer
{
[JsonProperty("@odata.nextLink")]
public string OdataNextLink { get; set; }
public List<Microsoft.Graph.Models.User> value { get; set; }
}
// Or use your custom class to parse the User object
public class MyUser
{
public string id { get; set; }
public string displayName { get; set; }
}
public class MyUsersContainer
{
[JsonProperty("@odata.nextLink")]
public string OdataNextLink { get; set; }
public List<MyUser> value { get; set; }
}
A container class type is needed for the method ListFromMsGraph to parse the results. All MS Graph LIST APIs return data as in
{
"@odata.nextLink":"https://...",
"value":[
{
...
},
{
...
}
]
}
Notice it is a JSON object with a "@odata.nextLink" field and a "value" field.
var graphClientId = "YOUR_CLIENT_ID";
var graphClientsecret = "YOUR_CLIENT_SECRET";
azureClient.InitiateGraphClient(graphClientId,graphClientsecret);
string uri = "https://graph.microsoft.com/beta/users"; //optionally add MS Graph API-supported query parameters, such as $filter, $top
List<MyUser> users = await azClient.ListFromMsGraph<MyUser, MyUsersContainer>(uri);
Another method to get results from MS Graph API is SendToMsGraphAPI
public class MyUser
{
public string id { get; set; }
public string displayName { get; set; }
}
string userId = "";
string uri = $"https://graph.microsoft.com/beta/users/{userId}";
// The returned respose content is data in JSON string
var resultsJson = await azureClient.SendToMsGraphAPI(uri,HttpMethod.Get);
MyUser user = JsonConvert.DeserializeObject<MyUser>(resultsJson);
using static GoCloud.AzureClient.Utils;
// EmptyString
string str1 = "";
string str2 = "myTeStStr";
str1.EmptyString(); // => returns True
str2.EmptyString(); // => returns False
// StringContains
string searchStr1 = "est";
string searchStr2 = "ddd";
str2.StringContains(searchStr1); // => returns True
str2.StringContains(searchStr2); // => returns False
// IgnoreSerializeJson and SelectSerializeJson
MyUser user = new MyUser { id="010", displayName = "user1" };
string jsonStr1 = IgnoreSerializeJson(user, ignoreProp:"displayName"); // => returns a JSON string { "id": "010" }
string jsonStr2 = SelectSerializeJson(user, selectProp:"displayName"); // => returns a JSON string { "displayName": "user1" }
For more Utils methods, please see the code repo.
var workspaceId = "YOUR_WORKSPACE_ID";
var query = "AzureActivity | summarize count() by Category";
var timeSpan = TimeSpan.FromDays(1);
// Returns rows as string arrays
var rows = await azureClient.QueryWorkspaceLogs(workspaceId, query, timeSpan);
// Or get the full LogsTable
var table = await azureClient.QueryWorkspaceTable(workspaceId, query, timeSpan);
// Set the App Insights token first
azureClient.SetAppInsightToken();
var appId = "YOUR_APP_INSIGHTS_APP_ID";
var query = "requests | summarize count() by resultCode";
var result = await azureClient.QueryAppInsights(appId, query);
var kvName = "YOUR_KEYVAULT_NAME";
var secretClient = azureClient.GetSecretClient(kvName);
// Get a secret
var secret = secretClient.GetSecret("my-secret");
Inherit from SQLBase<T> to get built-in SQL bulk operations.
public class MyRecord : SQLBase<MyRecord>
{
public string Name { get; set; }
public int Value { get; set; }
}
// Bulk save
using var con = new SqlConnection(connectionString);
con.Open();
MyRecord.Save(con, records, "dbo.MyTable");
// List all
var items = MyRecord.List(con, "dbo.MyTable");
// Clean up
MyRecord.CleanUp(con, "dbo.MyTable");
MyRecord.CleanUpToday(con, "dbo.MyTable", "DateColumn");
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.1.9 | 113 | 4/1/2026 | |
| 1.1.8 | 104 | 4/1/2026 | |
| 1.1.7 | 215 | 10/20/2025 | |
| 1.1.6 | 1,288 | 8/22/2024 | |
| 1.1.5 | 202 | 8/21/2024 | |
| 1.1.4 | 209 | 8/21/2024 | |
| 1.1.3 | 210 | 8/21/2024 | |
| 1.1.2 | 218 | 8/21/2024 | |
| 1.1.1 | 222 | 6/17/2024 | |
| 1.1.0 | 220 | 5/7/2024 | |
| 1.0.9 | 264 | 3/20/2024 | |
| 1.0.8 | 211 | 2/16/2024 | |
| 1.0.7 | 234 | 2/6/2024 | |
| 1.0.6 | 219 | 1/25/2024 | |
| 1.0.5 | 196 | 1/24/2024 | |
| 1.0.4 | 194 | 1/22/2024 | |
| 1.0.3 | 202 | 1/22/2024 | |
| 1.0.2 | 207 | 1/22/2024 | |
| 1.0.1 | 199 | 1/22/2024 | 1.0.1 is deprecated because it is no longer maintained. |
| 1.0.0 | 213 | 1/22/2024 | 1.0.0 is deprecated because it is no longer maintained. |