Skip to content

Add GetVirtualNetwork to network samples #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ func getVnetClient() network.VirtualNetworksClient {
return vnetClient
}

// GetVirtualNetwork gets info on a virtual network
func GetVirtualNetwork(ctx context.Context, vnetName string) (network.VirtualNetwork, error) {
vnetClient := getVnetClient()
return vnetClient.Get(ctx, config.GroupName(), vnetName, "")
}

// CreateVirtualNetwork creates a virtual network
func CreateVirtualNetwork(ctx context.Context, vnetName string) (vnet network.VirtualNetwork, err error) {
vnetClient := getVnetClient()
Expand Down
6 changes: 6 additions & 0 deletions network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ func TestNetwork(t *testing.T) {
}
t.Logf("created vnet with 2 subnets")

_, err = GetVirtualNetwork(ctx, virtualNetworkName)
if err != nil {
t.Fatalf("failed to get vnet: %v\n", err.Error())
}
t.Logf("got vnet %s\n", virtualNetworkName)

_, err = CreateNetworkSecurityGroup(ctx, nsgName)
if err != nil {
t.Fatalf("failed to create NSG: %v\n", err.Error())
Expand Down