Skip to content

Commit 386112a

Browse files
committed
Add deployment to resources.ps1
1 parent 2d456ab commit 386112a

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/AzureRM.Resources.ps1

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@
1111
$client = Get-ResourcesClient $context
1212
}
1313
PROCESS {
14-
$getTask = $client.ResourceGroups.GetAsync($Name, [System.Threading.CancellationToken]::None)
15-
$rg = $getTask.Result
16-
$resourceGroup = Get-ResourceGroup $Name $Location
17-
Write-Output $resourceGroup
14+
if($Name -eq $null) {
15+
$getTask = $client.ResourceGroups.ListAsync($null, [System.Threading.CancellationToken]::None)
16+
$rg = $getTask.Result
17+
$resourceGroup = List-ResourceGroup
18+
Write-Output $resourceGroup
19+
} else {
20+
$getTask = $client.ResourceGroups.GetAsync($Name, [System.Threading.CancellationToken]::None)
21+
$rg = $getTask.Result
22+
$resourceGroup = Get-ResourceGroup $Name $Location
23+
Write-Output $resourceGroup
24+
}
1825
}
1926
END {}
2027

@@ -43,6 +50,32 @@ function New-AzureRmResourceGroup
4350

4451
}
4552

53+
function New-AzureRmResourceGroupDeployment
54+
{
55+
[CmdletBinding()]
56+
param(
57+
[string] [alias("ResourceGroupName")] $Name,
58+
[string] $TemplateFile,
59+
[string] $serverName,
60+
[string] $databaseName,
61+
[string] $storageName,
62+
[string] $version,
63+
[string] $EnvLocation,
64+
[string] $administratorLogin,
65+
[switch] $Force)
66+
BEGIN {
67+
$context = Get-Context
68+
$client = Get-ResourcesClient $context
69+
}
70+
PROCESS {
71+
$createParms = New-Object -Type Microsoft.Azure.Management.Resources.Models.Deployment
72+
$createTask = $client.Deployments.CreateOrUpdateAsync($Name, $Name, $createParms, [System.Threading.CancellationToken]::None)
73+
$rg = $createTask.Result
74+
}
75+
END {}
76+
77+
}
78+
4679
function Remove-AzureRmResourceGroup
4780
{
4881
[CmdletBinding()]
@@ -89,4 +122,9 @@ function Get-ResourceGroup {
89122
param([string] $name, [string] $location)
90123
$rg = New-Object PSObject -Property @{"ResourceGroupName" = $name; "Location" = $location; }
91124
return $rg
125+
}
126+
127+
function List-ResourceGroup {
128+
$rg = New-Object PSObject -Property @{"ResourceGroupName" = $name; "Location" = $location; }
129+
return $rg
92130
}

0 commit comments

Comments
 (0)