示例#1
0
        public PSVirtualHub GetVirtualHub(string resourceGroupName, string name)
        {
            try
            {
                //// The following code will throw if resource is not found
                MNM.VirtualHub virtualHub = this.VirtualHubClient.Get(resourceGroupName, name);

                PSVirtualHub psVirtualHub = ToPsVirtualHub(virtualHub);
                psVirtualHub.ResourceGroupName = resourceGroupName;
                return(psVirtualHub);
            }
            catch (Exception ex)
            {
                if (ex is Microsoft.Azure.Management.Network.Models.ErrorException || ex is Rest.Azure.CloudException)
                {
                    return(null);
                }
                throw;
            }
        }
        public PSVirtualHub GetVirtualHub(string resourceGroupName, string name)
        {
            MNM.VirtualHub virtualHub   = null;
            PSVirtualHub   psVirtualHub = null;

            try
            {
                //// The following code will throw if resource is not found
                virtualHub = this.VirtualHubClient.Get(resourceGroupName, name);

                psVirtualHub = ToPsVirtualHub(virtualHub);
                psVirtualHub.ResourceGroupName = resourceGroupName;
            }
            catch (Microsoft.Azure.Management.Network.Models.ErrorException)
            {
                // Resource is not present
                return(psVirtualHub);
            }

            return(psVirtualHub);
        }