# High Availability Using Azure Availability Sets

## Overview

Azure Availability Sets provide high availability for Tessell database services in Azure regions that do not support Availability Zones. Availability Sets distribute your database instances across multiple fault domains (physical racks) and update domains (maintenance cycles) to protect against hardware failures and minimize downtime during Azure maintenance.

Tessell automatically creates Availability Sets when you provision High Availability database services in regions without Availability Zone support.

**Example regions without Availability Zone support:**

* North Central US
* West Central US
* West US
* UK West
* Canada East
* Australia Southeast

**Note:** Availability Sets and Availability Zones are mutually exclusive. If your region supports Availability Zones, Tessell uses zones instead.

## Prerequisites

Complete these one-time setup steps in your Azure subscription before provisioning database services with Availability Sets.

### Step 1: Register Azure Feature

Premium SSD v2 storage requires a subscription-level feature registration to work with Availability Sets.

1. Open Azure Cloud Shell or use Azure CLI locally.
2. Set your subscription:

```bash
 az account set --subscription "<subscription-id>"
```

3. Register the feature:

```bash
 az feature registration create --namespace Microsoft.Compute --name PV2WithAVSetRegionWithoutZone
```

4. Verify registration is complete:

```bash
 az feature registration show --provider Microsoft.Compute --name PV2WithAVSetRegionWithoutZone
```

5. Wait until the output shows `"state": "Registered"` before proceeding.

**Note:** Feature registration typically completes within a few minutes but may take longer. Repeat this registration for each Azure subscription where you plan to use Availability Sets.

### Step 2: Add Service Principal Permissions

Add these permissions to your Tessell Service Principal:

```
Microsoft.Compute/availabilitySets/read
Microsoft.Compute/availabilitySets/write
Microsoft.Compute/availabilitySets/delete
Microsoft.Compute/availabilitySets/vmSizes/read
```

These permissions allow Tessell to create and manage Availability Sets in your subscription.

## How It Works

### Fault Domains and Update Domains

Azure Availability Sets use two mechanisms to ensure high availability:

**Fault Domains** provide rack-level isolation. Each fault domain represents a separate physical rack with independent power and networking. If one rack fails, instances in other fault domains remain available.

**Update Domains** control planned maintenance. Azure updates one update domain at a time, ensuring not all instances are rebooted simultaneously during maintenance.

Tessell automatically configures:

* Maximum available fault domains for your region (typically 2 or 3)
* 5 update domains (Azure recommended default)

Azure distributes your instances in a round-robin method across these domains automatically.

### High Availability Configuration

**HA Nodes (Primary + Standby):** Both instances are placed in the same Availability Set, allowing Azure to distribute them across different fault domains. This ensures a single rack failure or maintenance event does not affect both instances.

**Disaster Recovery Instances:** DR instances receive separate Availability Sets to maintain operational isolation from HA nodes.

**Read Replicas:** Use the same Availability Set as the HA configuration.

## Important Considerations

### Storage Operations

When working with snapshots and clones:

* Disk attachment may be delayed while Azure performs background data alignment across fault domains
* Storage resize and encryption key changes are temporarily blocked during this alignment
* Operations resume automatically once alignment completes

### VM Sizing

Azure distributes VMs across fault domains based on available capacity. Occasionally, a specific VM size may not be available in all fault domains, which can cause provisioning or resize operations to fail even when regional capacity exists.

**If this occurs:**

* Retry the operation (capacity may become available)
* Select a different VM size
* Contact Tessell support for assistance

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tessell.com/tessell/azure_avset_doc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
