Skip navigation

Azure Container Instances .NET code samples for documentation

This .NET Core 2.0 console application demonstrates several common Azure Container Instances (ACI) operations in C# using the fluent APIs in the Azure Management Libraries for .NET.

The code in this project is ingested into one or more articles on docs.microsoft.com. Modifying the existing #region tags in the sample source may impact the rendering of code snippets on docs.microsoft.com, and is discouraged.

Features

The code in this sample project demonstrates the following operations:

  • Authenticate with Azure
  • Create resource group
  • Create single- and multi-container container groups
    • Expose application container to internet with public DNS name
    • Multi-container group includes both application and sidecar containers
    • Demonstrate async container group create
    • Run a task-based container with custom command line and environment variables
  • Get and print container group details
  • Delete container groups
  • Delete resource group

Getting Started

Prerequisites

Run the sample

  1. Use the Azure CLI (or Cloud Shell) to generate an Azure credentials file (more info)

az ad sp create-for-rbac --sdk-auth > my.azureauth

  1. Set environment variable AZURE_AUTH_LOCATION to the full path of the credentials file
  2. git clone https://github.com/Azure-Samples/aci-docs-sample-dotnet
  3. cd aci-docs-sample-dotnet
  4. dotnet run

Resources