forked from phucbmt/tech
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdepl.ps1
More file actions
72 lines (64 loc) · 1.98 KB
/
depl.ps1
File metadata and controls
72 lines (64 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Remove-Item long.json
Remove-Item long1.json
Invoke-WebRequest 'https://raw.githubusercontent.com/ddao2604/tech/main/long.json' -OutFile long.json
Invoke-WebRequest 'https://raw.githubusercontent.com/ddao2604/tech/main/long1.json' -OutFile long1.json
$id = (Get-AzContext).Account.Id
$name = $id.Split("@")[0]
$ts = Get-Date -Format "dd-MM-HH"
$name = $ts + "-"+$name
(Get-Content long.json).Replace('XNX', $name) | Set-Content long.json
(Get-Content long1.json).Replace('XNX', $name) | Set-Content long1.json
$loclist = "EastUS,NorthEurope,WestEurope,SoutheastAsia,EastAsia,WestUS,JapanWest,JapanEast,EastUS2,NorthCentralUS,SouthCentralUS,BrazilSouth,AustraliaEast,AustraliaSoutheast,CentralUS,CentralIndia,SouthIndia,CanadaCentral,CanadaEast,WestUS2,UKWest,UKSouth,KoreaCentral,FranceCentral,SouthAfricaNorth,SwitzerlandNorth,GermanyWestCentral,UAENorth,NorwayEast,WestUS3,SwedenCentral,PolandCentral,ItalyNorth,IsraelCentral"
$loclist = $loclist.split(",");
$run = $true
$ii = 5
While($run)
{
$tt = $ii + 1
$st = '"capacity":'+$ii.ToString()
$ft = '"capacity":'+$tt.ToString()
(Get-Content long.json).Replace($ft, $st) | Set-Content long.json
foreach ($i in $loclist) {
$Resource = Get-AzAppServicePlan -ResourceGroupName $i
$tname = $Resource.name
$i
if($tname)
{
$wk = $Resource.Sku.Capacity
$wk
if($wk -lt 5)
{
$nw = $wk + 1
Set-AzAppServicePlan -Name $tname -ResourceGroupName $i -NumberofWorkers $nw
}
else
{
$loclist = $loclist | Where-Object { $_ -ne $i }
}
}
else
{
New-AzResourceGroup -Name $i -Location $i -Force
New-AzResourceGroupDeployment -ResourceGroupName $i -TemplateFile long.json
}
}
$len = $loclist.Length
if($len -lt 1)
{
break
}
if($ii -eq 1)
{
}
else
{
$ii = $ii - 1
}
$time = Get-Random -Minimum 50 -Maximum 80
$waitSeconds = $time
Start-Sleep -Seconds 0
$waitSeconds..0 | Foreach-Object {
Write-Host "`r Time Remaining: $_ " -NoNewline -foregroundcolor green
Start-Sleep -Seconds 1
}
}