Microsoft.Azure.Commands.Network.VirtualNetworkBaseCmdlet.IsVirtualNetworkPresent C# (CSharp) Method

IsVirtualNetworkPresent() public method

public IsVirtualNetworkPresent ( string resourceGroupName, string name ) : bool
resourceGroupName string
name string
return bool
        public bool IsVirtualNetworkPresent(string resourceGroupName, string name)
        {
            try
            {
                GetVirtualNetwork(resourceGroupName, name);
            }
            catch (Microsoft.Rest.Azure.CloudException exception)
            {
                if (exception.Response.StatusCode == HttpStatusCode.NotFound)
                {
                    // Resource is not present
                    return false;
                }

                throw;
            }

            return true;
        }