This repository contains .NET samples for Azure Resource Manager Compute.BulkActions operations such as start, deallocate, delete, and hibernate, plus operation management (cancel and status) and retry/fallback policies.
The samples are intentionally small and focused. Each project folder represents a self-contained sample built on the Azure.ResourceManager.Compute.BulkActions package.
All operations are extension methods on ResourceGroupResource from the Azure.ResourceManager.Compute.BulkActions package. Every endpoint takes an explicit AzureLocation argument identifying the region where the operation runs — a resource group's location can differ from the location of the resources it contains, so the location is supplied by the caller rather than inferred from the resource group:
| Endpoint (sync / async) | Request content | Result type |
|---|---|---|
BulkStartOperation / BulkStartOperationAsync |
ExecuteStartContent |
StartResourceOperationResult |
BulkDeallocateOperation / BulkDeallocateOperationAsync |
ExecuteDeallocateContent |
DeallocateResourceOperationResult |
BulkDeleteOperation / BulkDeleteOperationAsync |
ExecuteDeleteContent (IsForceDeletion) |
DeleteResourceOperationResult |
BulkHibernateOperation / BulkHibernateOperationAsync |
ExecuteHibernateContent |
HibernateResourceOperationResult |
BulkCancelOperations / BulkCancelOperationsAsync |
CancelBulkOperationsContent |
CancelBulkOperationsResult |
BulkGetOperationsStatus / BulkGetOperationsStatusAsync |
GetBulkOperationStatusContent |
GetBulkOperationStatusResult |
| Project | What it demonstrates |
|---|---|
BulkStart |
Start existing VMs via BulkStartOperation |
BulkDeallocate |
Deallocate existing VMs via BulkDeallocateOperation |
BulkDelete |
Delete existing VMs via BulkDeleteOperation (with optional force delete) |
BulkHibernate |
Hibernate existing VMs via BulkHibernateOperation |
BulkCancelOperations |
Cancel in-flight operations via BulkCancelOperations |
BulkGetOperationStatus |
Query operation status via BulkGetOperationsStatus |
OperationFallback |
Retry policy and OnFailureAction fallback scenarios |
AllScenarios |
Combined example flow (start → hibernate → deallocate → delete) using shared helpers |
- .NET 10 SDK
- An Azure subscription
- An existing Azure resource group
- Azure CLI installed and signed in with
az login - NuGet feeds configured through
src/NuGet.config
DefaultAzureCredential is used throughout the samples, so az login is the simplest way to authenticate locally.
git clone https://github.com/Azure/azure-compute-bulkactions-dotnet-samples.git
cd azure-compute-bulkactions-dotnet-samplesaz loginMost samples use static placeholder values (subscription id, resource group, VM names) declared at the top of their Program.cs. Replace those with your own values before running.
The OperationFallback sample is configured through its appsettings.json file instead.
From the repository root:
dotnet build src/azure-compute-bulkactions-dotnet-samples.slnFrom src:
dotnet builddotnet run --project src/BulkStart/BulkStart.csproj
dotnet run --project src/BulkDeallocate/BulkDeallocate.csproj
dotnet run --project src/BulkDelete/BulkDelete.csproj
dotnet run --project src/BulkHibernate/BulkHibernate.csproj
dotnet run --project src/BulkCancelOperations/BulkCancelOperations.csproj
dotnet run --project src/BulkGetOperationStatus/BulkGetOperationStatus.csproj
dotnet run --project src/OperationFallback/OperationFallback.csproj
dotnet run --project src/AllScenarios/AllScenarios.csprojIn any sample folder under src/<ProjectName>, you can usually run:
dotnet runsrc/
├── Common/
├── BulkStart/
├── BulkDeallocate/
├── BulkDelete/
├── BulkHibernate/
├── BulkCancelOperations/
├── BulkGetOperationStatus/
├── OperationFallback/
├── AllScenarios/
├── NuGet.config
└── azure-compute-bulkactions-dotnet-samples.sln
- src/OperationFallback/README.md: retry policy and
OnFailureActionfallback scenarios - src/BulkGetOperationStatus/README.md: querying operation status and interpreting the response
- src/BulkDeallocate/docs/deallocate-preempts-start.md: behavior and API semantics when deallocate preempts a pending or in-progress start
All sample projects reference src/Common, which contains the shared helper layer used across the repository:
BulkActionsOperations.cs: wrappers around the six Compute.BulkActions endpoints (submit + poll to completion)HelperMethods.cs: subscription/resource-group resolution, VM resource-id builders, operation-id extraction, and status pollingConsoleProgressRenderer.cs: single-line progress updates for longer-running flowsSetHeaderPolicy.cs: example of adding a custom ARM pipeline header policy