Skip to content

Commit

Permalink
resource group name as a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-shandar committed Sep 9, 2017
1 parent 96972d2 commit 255e154
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions experiments/Compute.Experiments/AzureRM.Compute.Experiments.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function New-AzVm {
}

# Resource Group
$resourceGroup = $rgi.GetOrCreate($Name + "ResourceGroup", $locationi.Value);
$resourceGroup = $rgi.GetOrCreate($Name + "ResourceGroup", $locationi.Value, $null);

if (-not $Credential) {
$Credential = Get-Credential
Expand Down Expand Up @@ -208,7 +208,7 @@ class AzureObject {
return $null;
}

[object] Create([string] $name, [string] $location) {
[object] Create([string] $name, [string] $location, [string] $resourceGroupName) {
return $null;
}

Expand All @@ -225,11 +225,11 @@ class AzureObject {
}
}

[object] GetOrCreate([string] $name, [string] $location) {
[object] GetOrCreate([string] $name, [string] $location, [string] $resourceGroupName) {
if ($this.Name) {
return $this.GetInfo();
} else {
$result = $this.Create($name, $location);
$result = $this.Create($name, $location, $resourceGroupName);
$this.Name = $name;
return $result;
}
Expand All @@ -244,7 +244,7 @@ class ResourceGroup: AzureObject {
return Get-AzureRmResourceGroup -Name $this.Name;
}

[object] Create([string] $name, [string] $location) {
[object] Create([string] $name, [string] $location, [string] $resourceGroupName) {
return New-AzureRmResourceGroup -Name $name -Location $location;
}
}
Expand All @@ -261,6 +261,18 @@ class VirtualNetwork: Resource1 {
[object] GetInfo() {
return Get-AzureRmVirtualNetwork -Name $this.Name;
}

[object] Create([string] $name, [string] $location, [string] $resourceGroupName) {
$subnetConfig = New-AzureRmVirtualNetworkSubnetConfig `
-Name "Subnet" `
-AddressPrefix "192.168.1.0/24"
return New-AzureRmVirtualNetwork `
-ResourceGroupName $resourceGroupName `
-Location $location `
-Name $name `
-AddressPrefix "192.168.0.0/16" `
-Subnet $subnetConfig
}
}

class PublicIpAddress: Resource1 {
Expand Down

0 comments on commit 255e154

Please sign in to comment.