Skip to content

Azure/azure-computeschedule-dotnet-samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure Compute Schedule .NET Samples

This repository contains .NET samples for Azure Compute Schedule operations such as create, start, deallocate, delete, hibernate, and Flex create.

The samples are intentionally small and focused. Each project folder represents a self-contained sample and may use its own configuration pattern depending on the scenario it demonstrates.

Projects

Project What it demonstrates
ExecuteCreate Standard VM create flow with network and disk setup
ExecuteCreateFlex Flex create flow with API and batch demo modes
ExecuteStart Start existing VMs
ExecuteDeallocate Deallocate existing VMs
ExecuteDelete Delete existing VMs
ExecuteHibernate Hibernate existing VMs
OperationFallback Retry and fallback scenarios for start, hibernate, and create operations
AllScenarios Combined example flow using shared helpers

Prerequisites

  • .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.

Quick Start

1. Clone the repository

git clone https://github.com/Azure/azure-computeschedule-dotnet-samples.git
cd azure-computeschedule-dotnet-samples

2. Sign in to Azure

az login

3. Choose and configure a sample

Review the project folder for the sample you want to run and apply the configuration model documented there.

Depending on the sample, that may involve:

  • setting environment variables or a local .env file
  • updating appsettings.json
  • updating sample values in Program.cs
  • replacing sample VM names, resource IDs, subscription IDs, or resource group names

Sample-specific documentation should be treated as the source of truth for configuration.

Build

From the repository root:

dotnet build src/azure-computeschedule-dotnet-samples.sln

From src:

dotnet build

Run Samples

From the repository root

Use the project file path for whichever sample you want to run:

dotnet run --project src/ExecuteCreate/ExecuteCreate.csproj
dotnet run --project src/ExecuteCreateFlex/ExecuteCreateFlex.csproj -- --api-demo --resource-count 5
dotnet run --project src/ExecuteStart/ExecuteStart.csproj
dotnet run --project src/ExecuteDeallocate/ExecuteDeallocate.csproj
dotnet run --project src/ExecuteDelete/ExecuteDelete.csproj
dotnet run --project src/ExecuteHibernate/ExecuteHibernate.csproj
dotnet run --project src/OperationFallback/OperationFallback.csproj
dotnet run --project src/AllScenarios/AllScenarios.csproj

From src

dotnet run --project ./ExecuteCreate/ExecuteCreate.csproj
dotnet run --project ./ExecuteCreateFlex/ExecuteCreateFlex.csproj -- --api-demo --resource-count 5
dotnet run --project ./ExecuteStart/ExecuteStart.csproj
dotnet run --project ./ExecuteDeallocate/ExecuteDeallocate.csproj
dotnet run --project ./ExecuteDelete/ExecuteDelete.csproj
dotnet run --project ./ExecuteHibernate/ExecuteHibernate.csproj
dotnet run --project ./OperationFallback/OperationFallback.csproj
dotnet run --project ./AllScenarios/AllScenarios.csproj

From an individual project directory

In any sample folder under src/<ProjectName>, you can usually run:

dotnet run

Some projects support additional command-line arguments. For example, ExecuteCreateFlex can be run with:

dotnet run -- --api-demo --resource-count 5
dotnet run -- --batch-demo --resource-count 200

Sample Notes

For detailed setup, configuration, and usage instructions, check the documentation and source files in the folder for the sample you want to run.

Project Structure

src/
├── Common/
├── ExecuteCreate/
├── ExecuteCreateFlex/
├── ExecuteStart/
├── ExecuteDeallocate/
├── ExecuteDelete/
├── ExecuteHibernate/
├── OperationFallback/
├── AllScenarios/
├── NuGet.config
└── azure-computeschedule-dotnet-samples.sln

Documentation

Shared Code

All sample projects reference src/Common, which contains the shared helper layer used across the repository:

  • ComputescheduleOperations.cs: common create, start, deallocate, delete, and hibernate operation flows
  • HelperMethods.cs: resource helpers, request builders, VNet creation, data disk creation, and operation polling
  • ConsoleProgressRenderer.cs: single-line progress updates for longer-running flows
  • SetHeaderPolicy.cs: example of adding a custom ARM pipeline header policy

About

Azure Compute Schedule Samples: practical .NET examples for Azure Resource Manager ComputeSchedule operations

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages