Azure.ResourceManager.Hci 1.2.0

Prefix Reserved
dotnet add package Azure.ResourceManager.Hci --version 1.2.0                
NuGet\Install-Package Azure.ResourceManager.Hci -Version 1.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Azure.ResourceManager.Hci" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Azure.ResourceManager.Hci --version 1.2.0                
#r "nuget: Azure.ResourceManager.Hci, 1.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Azure.ResourceManager.Hci as a Cake Addin
#addin nuget:?package=Azure.ResourceManager.Hci&version=1.2.0

// Install Azure.ResourceManager.Hci as a Cake Tool
#tool nuget:?package=Azure.ResourceManager.Hci&version=1.2.0                

Microsoft Azure Stack HCI management client library for .NET

Microsoft Azure VMware Solution is a VMware validated solution with ongoing validation and testing of enhancements and upgrades. Microsoft manages and maintains the private cloud infrastructure and software. It allows you to focus on developing and running workloads in your private clouds to deliver business value.

This library supports managing Microsoft Azure Stack HCI resources.

This library follows the new Azure SDK guidelines, and provides many core capabilities:

- Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET.
- Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing.
- HTTP pipeline with custom policies.
- Better error-handling.
- Support uniform telemetry across all languages.

Getting started

Install the package

Install the Azure Stack HCI management library for .NET with NuGet:

dotnet add package Azure.ResourceManager.Hci

Prerequisites

Authenticate the Client

To create an authenticated client and start interacting with Microsoft Azure resources, see the quickstart guide here.

Key concepts

Key concepts of the Microsoft Azure SDK for .NET can be found here.

Documentation

Documentation is available to help you learn how to use this package:

Examples

Prerequisites
  1. Get the Azure token
TokenCredential cred = new DefaultAzureCredential();
ArmClient client = new ArmClient(cred);
  1. Update the parameters given below
public string subscriptionId = "00000000-0000-0000-0000-000000000000";  // Replace with your subscription ID
public string resourceGroupName = "hcicluster-rg";                      // Replace with your resource group name

Extension Management

Prerequisites
  1. Update the parameters given below
public string clusterName = "HCICluster";                               // Replace with your cluster name
Installing Extensions as part of enabling capabilities
Install Azure Monitor Windows Agent Extension
// Create the Payload and invoke the operation
string extensionName = "AzureMonitorWindowsAgent";
string publisherName = "Microsoft.Azure.Monitor";
string arcExtensionName = "AzureMonitorWindowsAgent";
string typeHandlerVersion = "1.10";
string workspaceId = "xx";  // workspace id for the log analytics workspace to be used with AMA extension
string workspaceKey = "xx"; // workspace key for the log analytics workspace to be used with AMA extension
bool enableAutomaticUpgrade = false;

ArcExtensionData data = new ArcExtensionData()
{
    Publisher = publisherName,
    ArcExtensionType = arcExtensionName,
    TypeHandlerVersion = typeHandlerVersion,
    Settings = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
    {
        ["workspaceId"] = workspaceId
    }),
    ProtectedSettings = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
    {
        ["workspaceKey"] = workspaceKey
    }),
    EnableAutomaticUpgrade = enableAutomaticUpgrade,
};

ResourceIdentifier arcSettingResourceId = ArcSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, "default");
ArcSettingResource arcSetting = client.GetArcSettingResource(arcSettingResourceId);
ArcExtensionCollection collection = arcSetting.GetArcExtensions();

// Create the Extension
var lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, extensionName, data);
ArcExtensionResource resource = lro.Value;
Install Windows Admin Centre Extension
// Create the payload and invoke the operation
string extensionName = "AdminCenter";
string publisherName = "Microsoft.AdminCenter";
string arcExtensionType = "AdminCenter";
string typeHandlerVersion = "1.10";
string portNumber = "6516"; //port to be associated with WAC
bool enableAutoUpgrade = false; // change to true to enable automatic upgrade

ArcExtensionData data = new ArcExtensionData()
{
    Publisher = publisherName,
    ArcExtensionType = arcExtensionType,
    TypeHandlerVersion = typeHandlerVersion,
    Settings = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
    {
        ["port"] = portNumber
    }),
    EnableAutomaticUpgrade = enableAutoUpgrade,
};
ResourceIdentifier arcSettingResourceId = ArcSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, "default");
ArcSettingResource arcSetting = client.GetArcSettingResource(arcSettingResourceId);
ArcExtensionCollection collection = arcSetting.GetArcExtensions();

// Create the Extension
var lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, extensionName, data);
ArcExtensionResource resource = lro.Value;
Install Azure Site Recovery Extension
string publisherName = "Microsoft.SiteRecovery.Dra";
string arcExtensionType = "Windows";
string extensionName = "AzureSiteRecovery";
ArcExtensionData data = new ArcExtensionData()
{
    Publisher = publisherName,
    ArcExtensionType = arcExtensionType,
    EnableAutomaticUpgrade = true,
    Settings = BinaryData.FromObjectAsJson(new Dictionary<string, object>()
    {
        { "SubscriptionId", "your SubscriptionId" },
        { "Environment", "AzureCloud" },
        { "ResourceGroup", "your ResourceGroup" },
        { "ResourceName", "your site recovery vault name" },
        { "Location", "your site recovery region" },
        { "SiteId", "Id for your recovery site" },
        { "SiteName", "your recovery site name" },
        { "PolicyId", "your resource id for recovery site policy" },
        { "PrivateEndpointStateForSiteRecovery", "None" },
    })
};

// Get Arc Extension Resource
ResourceIdentifier arcSettingResourceId = ArcSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, "default");
ArcSettingResource arcSetting = client.GetArcSettingResource(arcSettingResourceId);
ArcExtensionCollection collection = arcSetting.GetArcExtensions();

// Create the Extension
var lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, extensionName, data);
ArcExtensionResource resource = lro.Value;
Extension upgrade
string extensionName = "AzureMonitorWindowsAgent"; // Replace with your extension name Some common examples are: AzureMonitorWindowsAgent, AzureSiteRecovery, AdminCenter
string targetVersion = "1.0.18062.0"; //replace with extension version you want to install
ResourceIdentifier arcExtensionResourceId = ArcExtensionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, "default", extensionName);
ArcExtensionResource arcExtension = client.GetArcExtensionResource(arcExtensionResourceId);
// Invoke Upgrade operation
ArcExtensionUpgradeContent content = new ArcExtensionUpgradeContent()
{
    TargetVersion = targetVersion,
};
await arcExtension.UpgradeAsync(WaitUntil.Completed, content);
Deleting an ARC Extension
string extensionName = "AzureMonitorWindowsAgent"; // Replace with your extension name Some common examples are: AzureMonitorWindowsAgent, AzureSiteRecovery, AdminCenter
ResourceIdentifier arcExtensionResourceId = ArcExtensionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, "default", extensionName);
ArcExtensionResource arcExtension = client.GetArcExtensionResource(arcExtensionResourceId);
// Invoke the delete operation
await arcExtension.DeleteAsync(WaitUntil.Completed);

HCI Cluster Management

View HCI Clusters
Get Single HCI Cluster using Cluster Name
// Get the HCI Cluster
string clusterName = "HCICluster"; // Replace with your cluster name,
ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName);
HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId);

// Invoke get operation
HciClusterResource result = await hciCluster.GetAsync();
Delete Single HCI cluster
// Get the HCI Cluster
ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName);
HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId);

// Invoke delete operation
await hciCluster.DeleteAsync(WaitUntil.Completed);
Delete all HCI Clusters in a Resource Group
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);

// Get the collection of this HciClusterResource
HciClusterCollection collection = resourceGroupResource.GetHciClusters();

// Calling the delete function for all Cluster Resources in the collection
await foreach (HciClusterResource item in collection.GetAllAsync())
{
    // delete the item

    await item.DeleteAsync(WaitUntil.Completed);
}
Update HCI Cluster Properties
// Get the HCI Cluster
ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName);
HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId);
HciClusterPatch patch = new HciClusterPatch()
{
    Tags =
    {
        { "key", "value" }
    },
    DesiredProperties = new HciClusterDesiredProperties()
    {
        WindowsServerSubscription = WindowsServerSubscription.Enabled,  // It can Enabled or Disabled
        DiagnosticLevel = HciClusterDiagnosticLevel.Basic,              // It can be Off, Basic or Enhanced
    },
};
HciClusterResource result = await hciCluster.UpdateAsync(patch);
Enable Azure Hybrid Benefits
  1. Invoke the Operation to Extend Azure Hybrid Benefit
ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName);
HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId);
SoftwareAssuranceChangeContent content = new SoftwareAssuranceChangeContent()
{
    SoftwareAssuranceIntent = SoftwareAssuranceIntent.Enable,
};
HciClusterResource result = (hciCluster.ExtendSoftwareAssuranceBenefitAsync(WaitUntil.Completed, content).Result).Value;

Code samples for using the management library for .NET can be found in the following locations

Troubleshooting

Next steps

For more information about Microsoft Azure SDK, see this website.

Contributing

For details on contributing to this repository, see the contributing guide.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (for example, label, comment). Follow the instructions provided by the bot. You'll only need to do this action once across all repositories using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any other questions or comments.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 9,889 8/14/2024
1.2.0-beta.1 972 12/1/2023
1.1.0 21,323 11/27/2023
1.0.2 14,688 6/1/2023
1.0.1 2,730 2/16/2023
1.0.0 4,573 8/29/2022
1.0.0-beta.5 1,055 7/13/2022
1.0.0-beta.4 234 6/2/2022
1.0.0-beta.3 271 4/8/2022
1.0.0-beta.2 166 3/31/2022
1.0.0-beta.1 177 3/4/2022