This commit is contained in:
Jorge Cotillo 2019-08-16 00:42:41 -07:00
Родитель 735b05069b
Коммит 31e188900e
2 изменённых файлов: 25 добавлений и 25 удалений

Просмотреть файл

@ -392,7 +392,7 @@ Class AzureResourceManagerDeploymentService: IDeploymentService {
$currentDeployment = $null;
# loop until the deployment succeeds or fails
$wait = 6;
$wait = 10;
$loop = 0;
$phase = 1;
do {
@ -528,27 +528,17 @@ Class AzureResourceManagerDeploymentService: IDeploymentService {
$dataToReturn.ResourceIds = $resourceIds;
$resourceStates = @();
# Let's use Azure Resource Graph to retrieve the
# latest resource state
$resourceIds | ForEach-Object {
$latestState = `
Search-AzGraph -Query "where id == '$_'";
if($latestState) {
# Let's initialize a new object
$resourceState = @{
ResourceId = $null
State = $null
};
$resourceState.ResourceId = $_;
# Convert to JSON latestState object
$resourceState.State = $latestState;
$resourceStates += $resourceState;
}
}
$allResourceIds = @();
# Adding single quotes to resource ids
$resourceIds | % { $allResourceIds += "'$_'" }
# Adding comma in between array items
$formattedResourceIds = $allResourceIds -join ",";
$resourceStates = `
Search-AzGraph -Query "where id in ($formattedResourceIds)";
$dataToReturn.ResourceStates = $resourceStates;
@ -588,9 +578,15 @@ Class AzureResourceManagerDeploymentService: IDeploymentService {
[void] CreateResourceGroup([string] $resourceGroupName,
[string] $location) {
try {
New-AzResourceGroup `
-Name $resourceGroupName `
-Location $location -Force;
$resourceGroupFound = `
Get-AzResourceGroup $resourceGroupName `
-ErrorAction SilentlyContinue;
if($null -eq $resourceGroupFound) {
New-AzResourceGroup `
-Name $resourceGroupName `
-Location $location -Force;
}
}
catch {
Write-Host "An error ocurred while running CreateResourceGroup";

Просмотреть файл

@ -139,6 +139,9 @@ Function New-Deployment {
if ($null -eq $subscriptionInformation) {
throw "Subscription: $($archetypeInstanceJson.Parameters.Subscription) not found";
}
# Let's get the current subscription context
$sub = Get-AzContext | Select-Object Subscription
# Do not change the subscription context if the operation is validate.
# This is because the script will expect the validation resource
@ -149,7 +152,8 @@ Function New-Deployment {
[Guid]::TryParse($subscriptionInformation.SubscriptionId, [ref]$subscriptionCheck) -and `
[Guid]::TryParse($subscriptionInformation.TenantId, [ref]$tenantIdCheck) -and `
$subscriptionCheck -ne [Guid]::Empty -and `
$tenantIdCheck -ne [Guid]::Empty) {
$tenantIdCheck -ne [Guid]::Empty -and
$subscriptionCheck -ne $sub.Subscription.Id) {
Write-Debug "Setting subscription context";
Set-SubscriptionContext `