/// <summary>
 /// Get the entity to update
 /// </summary>
 /// <returns>The AvailabilityGroupListener that will be updated</returns>
 protected override IEnumerable <AzureAvailabilityGroupListenerModel> GetEntity()
 {
     return(new List <AzureAvailabilityGroupListenerModel>()
     {
         ModelAdapter.GetAvailabilityGroupListener(ResourceGroupName, SqlVMGroupName, Name)
     });
 }
コード例 #2
0
        /// <summary>
        /// Gets one or more Availability Group Listener.
        /// </summary>
        /// <returns></returns>
        protected override IEnumerable <AzureAvailabilityGroupListenerModel> GetEntity()
        {
            ICollection <AzureAvailabilityGroupListenerModel> results = null;

            if (!string.IsNullOrEmpty(Name))
            {
                results = new List <AzureAvailabilityGroupListenerModel>();
                results.Add(ModelAdapter.GetAvailabilityGroupListener(ResourceGroupName, SqlVMGroupName, Name));
            }
            else
            {
                results = ModelAdapter.ListAvailabilityGroupListenerByGroup(ResourceGroupName, SqlVMGroupName);
            }
            return(results);
        }
コード例 #3
0
        /// <summary>
        /// Check to see if Availability Group Listener with the same name already exists in this resource group.
        /// </summary>
        /// <returns>Null if the Availability Group Listener doesn't exist.  Otherwise throws exception</returns>
        protected override IEnumerable <AzureAvailabilityGroupListenerModel> GetEntity()
        {
            try
            {
                ModelAdapter.GetAvailabilityGroupListener(this.ResourceGroupName, this.SqlVMGroupName, this.Name);
            }
            catch (CloudException)
            {
                return(null);
            }

            throw new PSArgumentException(
                      string.Format("An Availability Group Listener with name {0} in resource group {1} already exists. If you want to modify an existing Availability Group Listener you can use" +
                                    " Update-AzAvailabilityGroupListener command.", Name, ResourceGroupName),
                      "AvailabilityGroupListener");
        }