Availability Group Resource
Synopsis
Manages SQL Server Always On Availability Groups, including creation, configuration, and removal.
Type
Capabilities
- Get
- Set
- Delete
- Export
Properties
Connection properties
serverInstance
SQL Server instance name. Use . or (local) for the default instance, or
server\instance for named instances.
connectUsername
Username for SQL authentication. Omit for Windows authentication.
connectPassword
Password for SQL authentication.
Availability group properties
name
Name of the availability group.
automatedBackupPreference
Automated backup preference for the availability group: Primary,
SecondaryOnly, Secondary, or None.
failureConditionLevel
Failure condition level that triggers an automatic failover:
OnServerDown, OnServerUnresponsive, OnCriticalServerErrors,
OnModerateServerErrors, or OnAnyQualifiedFailureCondition.
healthCheckTimeout
Health check timeout value in milliseconds.
basicAvailabilityGroup
Whether this is a basic availability group (limited to two replicas and one database). Create-only; cannot be changed after creation.
databaseHealthTrigger
Whether the availability group supports database-level health detection.
dtcSupportEnabled
Whether DTC support is enabled for the availability group.
isDistributedAvailabilityGroup
Whether the availability group is a distributed availability group.
clusterType
Cluster type of the availability group: Wsfc, None, or External.
Create-only; cannot be changed after creation.
requiredSynchronizedSecondariesToCommit
Number of required synchronized secondaries to commit.
isContained
Whether the availability group is contained. Create-only; cannot be changed after creation.
Read-only properties
databases
Databases participating in the availability group.
primaryReplicaServerName
Name of the server that is the current primary replica.
localReplicaRole
Role of the local replica in the availability group: Resolving, Primary,
or Secondary.
uniqueId
Unique identifier of the availability group.
DSC properties
_exist
Whether the availability group should exist. Defaults to true.
Examples
Example 1 — Get an availability group
Example 2 — Create an availability group
resource_input=$(cat <<'EOF'
serverInstance: .
name: MyAG
automatedBackupPreference: Secondary
failureConditionLevel: OnCriticalServerErrors
healthCheckTimeout: 30000
databaseHealthTrigger: true
clusterType: Wsfc
EOF
)
dsc resource set -r OpenDsc.SqlServer/AvailabilityGroup --input "$resource_input"
Example 3 — Delete an availability group
Example 4 — Configuration document
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Production availability group
type: OpenDsc.SqlServer/AvailabilityGroup
properties:
serverInstance: "."
name: ProdAG
automatedBackupPreference: Secondary
failureConditionLevel: OnCriticalServerErrors
healthCheckTimeout: 30000
databaseHealthTrigger: true
dtcSupportEnabled: false
clusterType: Wsfc
requiredSynchronizedSecondariesToCommit: 1
Exit codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Error |
| 2 | Invalid JSON |
| 3 | Invalid argument |
| 4 | Unauthorized access |
| 5 | Invalid operation |