Skip to content

Commit 37f6262

Browse files
authored
Merge pull request #14 from IanB111/master
Support Multiple Azurestack's tasks on 1 server
2 parents b12cb8d + 59ebd23 commit 37f6262

7 files changed

Lines changed: 89 additions & 21 deletions

File tree

MasterScript.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ $info = @{
8888
}
8989

9090
$infoJson = ConvertTo-Json $info
91-
Set-Content -Path "C:\AZSAdminOMSInt\info.txt" -Value $infoJson
91+
Set-Content -Path "C:\AZSAdminOMSInt\info_$CloudName.txt" -Value $infoJson
9292

9393
#store passwords in txt files.
9494
$passwordText = $azureStackAdminPasswordSecureString | ConvertFrom-SecureString
95-
Set-Content -Path "C:\AZSAdminOMSInt\azspassword.txt" -Value $passwordText
95+
Set-Content -Path "C:\AZSAdminOMSInt\azspassword_$CloudName.txt" -Value $passwordText
9696

9797

9898
#Download Azure Stack Tools VNext
@@ -102,4 +102,4 @@ expand-archive vnext.zip -DestinationPath . -Force
102102

103103
# schedule windows scheduled task
104104
cd C:\AZSAdminOMSInt
105-
& .\schedule_usage_upload.ps1
105+
& .\schedule_usage_upload.ps1 -CloudName $CloudName

OpsDataToOMS.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
Start-Transcript -Path C:\AZSAdminOMSInt\OpsDataToOMS.log
1+
[CmdletBinding()]
2+
param(
3+
[Parameter(Mandatory = $true)]
4+
[string] $CloudName
5+
)
6+
7+
Start-Transcript -Path "C:\AZSAdminOMSInt\OpsDataToOMS_$CloudName.log"
28
Set-ExecutionPolicy Bypass -Force
39
Install-Module -Name OMSIngestionAPI -Force
410
Install-Module -Name AzureRM.OperationalInsights -Force
@@ -9,7 +15,7 @@ Import-Module -Name Azs.Fabric.Admin -Force
915

1016
#OMS Authentication Variables
1117

12-
$info = Get-Content -Raw -Path "C:\AZSAdminOMSInt\info.txt" | ConvertFrom-Json
18+
$info = Get-Content -Raw -Path "C:\AZSAdminOMSInt\info_$CloudName.txt" | ConvertFrom-Json
1319
$OMSWorkspaceId = $info.OmsWorkspaceID
1420
$OMSSharedKey = $info.OmsSharedKey
1521

@@ -19,7 +25,7 @@ $Location2 = $info.Region
1925
$cloudName2 = $info.CloudName
2026
$State2 = "active"
2127
$UserName2= $info.AzureStackAdminUsername
22-
$Password2= Get-Content "C:\AZSAdminOMSInt\azspassword.txt"| ConvertTo-SecureString
28+
$Password2= Get-Content "C:\AZSAdminOMSInt\azspassword_$CloudName.txt"| ConvertTo-SecureString
2329
$Credential2=New-Object PSCredential($UserName2,$Password2)
2430

2531
$deploymentGuid = $info.DeploymentGuid

asUsageToOMS.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
Start-Transcript -Path C:\AZSAdminOMSInt\asUsageToOMS.log
2-
& .\usagesummaryjson.ps1
1+
[CmdletBinding()]
2+
param(
3+
[Parameter(Mandatory = $true)]
4+
[string] $CloudName
5+
)
6+
7+
Start-Transcript -Path "C:\AZSAdminOMSInt\asUsageToOMS_$CloudName.log"
8+
& .\usagesummaryjson.ps1 -CloudName $CloudName
39

410
# set execution policy and import OMS Ingestion API.
511
Set-ExecutionPolicy -ExecutionPolicy Bypass -Force
612
Install-Module -Name AzureRM.OperationalInsights -Force
713
Install-Module -Name OMSIngestionAPI -Force
814

9-
& .\uploadToOMS.ps1
15+
& .\uploadToOMS.ps1 -CloudName $CloudName
1016
exit

docs/setup.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The following are required to setup the environment. You should gather these var
6868

6969
### Step 5 – Execute the script & update the scheduled task
7070
1. Run the InvokeMasterScript.ps1 now that the variables have been updated.
71-
2. Once the script completes, open Task Scheduler, right click on the newly created tasks named UsageDataUpload1 & OperationalDataUpload1, click Properties, and click "Change User or Group" (the Run As account) to the Admin UserName and Password of the UploadToOMSVM VM.
71+
2. Once the script completes, open Task Scheduler, right click on the newly created tasks named UsageDataUpload1_<CloudName> & OperationalDataUpload1_<CloudName>, click Properties, and click "Change User or Group" (the Run As account) to the Admin UserName and Password of the UploadToOMSVM VM.
7272
3. Click Run. Operational Data will be piushed every 13 minutes now. Usage Data will be pushed at 9am every day.
7373

7474
The scripts sets up 2 scheduled tasks:
@@ -79,6 +79,44 @@ The data are uploaded to the OMS workspace you specified in the ARM template.
7979

8080
Note: For usage data, the script is setup to query and upload usage data reported from the day before yesterday each time the scheduled task runs. Note that no usage data will be uploaded if there are no tenant usage during the timeframe specified.
8181

82+
## Deploy additional Data Collection scheduled tasks to a data collection VM
83+
### Step 1 - Get required variables
84+
The following are required to setup the environment. You should gather these variables before proceeding to the next step.
85+
#### DeploymentGUID = “<e.g. 41da4fdd-0e5f-4ecb-85d2-52cb85cd1fca>”
86+
1. Access the privileged endpoint
87+
2. Run Get-AzureStackStampInformation
88+
3. Find and copy the deploymentguid from the output
89+
#### azureStackAdminUsername ="<e.g. Serviceadmin@myazurestackinstance.onmicrosoft.com>"
90+
1. Update with the Azure Stack Service Admin account email
91+
#### azureStackAdminPassword = "<e.g. MyAzureStackPassword206!>"
92+
1. Update with the Azure Stack Service Admin account password
93+
#### CloudName ="<e.g. Orlando MTC>"
94+
1. Update location with the name of your Cloud, this is how most data will pivot in the views. Must be Unique with any AzureStack Tasks already running on the system
95+
#### Region = "<e.g. Orlando>"
96+
1. Update with the region name used when deploying Azure Stack
97+
#### Fqdn = "<e.g. azurestack.corp.microsoft.com>"
98+
1. Update with the FQDN name used when deploying Azure Stack
99+
#### OMSWorkpsaceID= "<ID of your log analytics workspace>"
100+
1. Update with the OMS/Log Analytics Workspace ID which can be found in the Advanced Settings pane of your Log Analytics workspace
101+
#### OMSSharedKey = "<Log Analytics Workspace Shared Key>"
102+
1. Update with the OMS/Log Analytics Workspace Primary Key found in the Advanced Settings pane of your Log Analytics workspace
103+
#### OEM = "<replace with your hardware vendor name>"
104+
1. Update with the name of your hardware vendor. Allows for reports in log analytics utilizing the OEM name.
105+
106+
### Step 2 – Update variables
107+
1. Open an elevated PowerShell ISE session
108+
2. Open the file C:\InvokeMasterScript.ps1
109+
3. Update the variables using the data gathered in Step 3
110+
111+
### Step 3 – Execute the script & update the scheduled task
112+
1. Run the InvokeMasterScript.ps1 now that the variables have been updated.
113+
2. Once the script completes, open Task Scheduler, right click on the newly created tasks named UsageDataUpload1_<CloudName> & OperationalDataUpload1_<CloudName>, click Properties, and click "Change User or Group" (the Run As account) to the Admin UserName and Password of the UploadToOMSVM VM.
114+
3. Click Run. Operational Data will be pushed every 13 minutes now. Usage Data will be pushed at 9am every day.
115+
116+
The scripts sets up 2 scheduled tasks:
117+
1. Upload of 1-day worth of usage data provided from the Provider Usage API at 9am every day.
118+
2. Upload of operational data every 13 minutes.
119+
82120
## Troubleshooting
83121
1. To verify that data is getting uploaded to OMS environment:
84122

@@ -154,4 +192,4 @@ For specific documentation on the Power BI dashboard template, refer to the [das
154192

155193
## Limitations
156194
1. As of 8/9/2017, there is 8mb size limit on the request that PowerBI uses to fetch data from OMS. This restriction is planned to be lifted in the future by the OMS Log Analytics team.
157-
2. If the restriction persists, one way to increase the number of days of usage data available (by 24x) is pull in daily aggregated usage data from OMS instead of hourly aggregated data. The obvious drawback for this method is that one will not be able to drilldown to the hourly level on the PowerBI dashboard.
195+
2. If the restriction persists, one way to increase the number of days of usage data available (by 24x) is pull in daily aggregated usage data from OMS instead of hourly aggregated data. The obvious drawback for this method is that one will not be able to drilldown to the hourly level on the PowerBI dashboard.

schedule_usage_upload.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
[CmdletBinding()]
2+
param(
3+
[Parameter(Mandatory = $true)]
4+
[string] $CloudName
5+
)
6+
17
#Usage Data Upload
28
$action = New-ScheduledTaskAction -Execute 'Powershell' `
3-
-Argument '.\asUsageToOMS.ps1' -WorkingDirectory "C:\AZSAdminOMSInt"
9+
-Argument (".\asUsageToOMS.ps1 -CloudName '{0}'" -f $CloudName) -WorkingDirectory "C:\AZSAdminOMSInt"
410
$description = "Daily upload of usage data from azure stack to OMS"
5-
$taskName = "UsageDataUpload1"
11+
$taskName = "UsageDataUpload1_$CloudName"
612

713
$trigger = New-ScheduledTaskTrigger -Daily -At 9am
814
$principal = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM"
@@ -14,9 +20,9 @@ Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $taskName -Pr
1420

1521
#Operational Data Upload
1622
$action = New-ScheduledTaskAction -Execute 'Powershell' `
17-
-Argument '.\OpsDataToOMS.ps1' -WorkingDirectory "C:\AZSAdminOMSInt"
23+
-Argument (".\OpsDataToOMS.ps1 -CloudName '{0}'" -f $CloudName) -WorkingDirectory "C:\AZSAdminOMSInt"
1824
$description = "Daily upload of operational data from azure stack to OMS"
19-
$taskName = "OperationalDataUpload1"
25+
$taskName = "OperationalDataUpload1_$CloudName"
2026

2127
$trigger = New-ScheduledTaskTrigger -once -at (Get-date) -RepetitionInterval (New-TimeSpan -Minutes 13) -RepetitionDuration (New-TimeSpan -Days 9999)
2228
$principal = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM"

uploadToOMS.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
Start-Transcript -Path C:\AZSAdminOMSInt\uploadtoOMS.log
1+
[CmdletBinding()]
2+
param(
3+
[Parameter(Mandatory = $true)]
4+
[string] $CloudName
5+
)
6+
7+
Start-Transcript -Path "C:\AZSAdminOMSInt\uploadtoOMS_$CloudName.log"
28
Set-ExecutionPolicy Bypass -Force
39
Install-Module -Name OMSIngestionAPI -Force
410
Install-Module -Name AzureRM.OperationalInsights -Force
@@ -9,7 +15,7 @@ Import-Module -Name Azs.Fabric.Admin -Force
915

1016
#OMS Authentication Variables
1117

12-
$info = Get-Content -Raw -Path "C:\AZSAdminOMSInt\info.txt" | ConvertFrom-Json
18+
$info = Get-Content -Raw -Path "C:\AZSAdminOMSInt\info_$CloudName.txt" | ConvertFrom-Json
1319
$OMSWorkspaceId = $info.OmsWorkspaceID
1420
$OMSSharedKey = $info.OmsSharedKey
1521

@@ -18,7 +24,7 @@ $Location2 = $info.Region
1824
$cloudName2 = $info.CloudName
1925
$State2 = "active"
2026
$UserName2= $info.AzureStackAdminUsername
21-
$Password2= Get-Content "C:\AZSAdminOMSInt\azspassword.txt"| ConvertTo-SecureString
27+
$Password2= Get-Content "C:\AZSAdminOMSInt\azspassword_$CloudName.txt"| ConvertTo-SecureString
2228
$Credential2=New-Object PSCredential($UserName2,$Password2)
2329

2430
$deploymentGuid = $info.DeploymentGuid

usagesummaryjson.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
.EXAMPLE
99
Export-AzureStackUsage -StartTime 2/15/2017 -EndTime 2/16/2017 -AzureStackDomain azurestack.local -AADDomain mydir.onmicrosoft.com -Granularity Hourly
1010
#>
11-
Start-Transcript -Path C:\AZSAdminOMSInt\usagesummaryjson.log
11+
[CmdletBinding()]
12+
param(
13+
[Parameter(Mandatory = $true)]
14+
[string] $CloudName
15+
)
16+
17+
Start-Transcript -Path "C:\AZSAdminOMSInt\usagesummaryjson_$CloudName.log"
1218

1319
function Export-AzureStackUsage {
1420
Param
@@ -194,9 +200,9 @@ $dayBeforeYesterday = $yesterday.addDays(-1)
194200
$usageStartTime = $dayBeforeYesterday.ToShortDateString()
195201
$usageEndTime = $yesterday.ToShortDateString()
196202

197-
$info = Get-Content -Raw -Path "C:\AZSAdminOMSInt\info.txt" | ConvertFrom-Json
203+
$info = Get-Content -Raw -Path "C:\AZSAdminOMSInt\info_$CloudName.txt" | ConvertFrom-Json
198204
$Username = $info.AzureStackAdminUsername
199-
$Password= Get-Content "C:\AZSAdminOMSInt\azspassword.txt"| ConvertTo-SecureString
205+
$Password= Get-Content "C:\AZSAdminOMSInt\azspassword_$CloudName.txt"| ConvertTo-SecureString
200206
$aadCred = New-Object PSCredential($Username, $Password)
201207
$cloudName2 = $info.CloudName
202208
$Location2 = $info.Region

0 commit comments

Comments
 (0)