Retrieving SQL Availability Group Properties Using the Command Line Interface

Updated

If you created a SQL Availability Group on SQL, then you can use XML to retrieve the Availability Group information from SQL.

Complete this procedure so that you have the required Availability Group element values for the command line interface.

Procedure

  1. Run the qlogin command to log on to the CommServe computer.

  2. Download the GetAvailabilityGroup.xml file and save it on the computer from where you will run the command.

  3. Open the GetAvailabilityGroup.xml file and update the XML parameters with the primary replica information.

  4. On the command line, go to <Software_Installation_Directory>/Base and type the following command:

    qoperation execute -af GetAvailabilityGroup.xml

    For more information about the additional parameters, see XML Request Parameters for SQL Availability Group Operations

  5. Run the qlogout command to log off the CommServe computer.

Response Parameters

Name

Description

uniqueID

A SQL generated ID for the group

name

The availability group name.

primaryReplicaServerName

The SQL primary replica server name.

backupPreference

The SQL availability group backup preference.

availabilityGroupListenerList

The SQL availability group listener name.

endpointURL

The SQL endpoint URL. This URL contains the instance and the port number.

Example

The following file retrieves the information about the SQL Availability groups where client IDA18 has the SQL Server instance IDA18 as the primary replica.

<App_GetAvailabilityGroupsReq> <sqlClient clientName="ida18"/> <instanceEntity clientName="ida18" instanceName="IDA18"/>
</App_GetAvailabilityGroupsReq>
    

The following file is the response.

<App_SQLAvailabilityGroups>
  <SQLAvailabilityGroupList>
    <uniqueId>b0c96d0e-e1ff-481c-9a41-a638e8693fb1</uniqueId>
    <name>AvailabilityG1</name>
    <primaryReplicaServerName>IDA18</primaryReplicaServerName>
    <backupPreference>2</backupPreference>
    <SQLAvailabilityGroupListenerName>
      <availabilityGroupListenerList>ida18_19_Ag1</availabilityGroupListenerName>
    </SQLAvailabilityGroupListenerName>
    <endpointURL>TCP://ida18.mycompany.com:5022</endpointURL>
  </SQLAvailabilityGroupList>
</App_SQLAvailabilityGroups>
    

Result

Use the response values as the values for the CreateAGClient Availability Group element parameters.

Was this page helpful?