Skip to content

Commit

Permalink
Fixed telemetry enablement scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Helder Pinto committed Mar 25, 2024
1 parent 536db2a commit 9506f57
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 31 deletions.
7 changes: 5 additions & 2 deletions src/optimization-engine/Deploy-AzureOptimizationEngine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ param (
[string] $SilentDeploymentSettingsPath,

[Parameter(Mandatory = $false)]
[hashtable] $ResourceTags = @{}
[hashtable] $ResourceTags = @{},

[Parameter(Mandatory = $false)]
[bool] $EnableDefaultTelemetry = $true
)

function ConvertTo-Hashtable {
Expand Down Expand Up @@ -693,7 +696,7 @@ if ("Y", "y" -contains $continueInput) {
-logAnalyticsWorkspaceName $laWorkspaceName -logAnalyticsWorkspaceRG $laWorkspaceResourceGroup `
-storageAccountName $storageAccountName -automationAccountName $automationAccountName `
-sqlServerName $sqlServerName -sqlDatabaseName $sqlDatabaseName -cloudEnvironment $AzureEnvironment `
-sqlAdminLogin $sqlAdmin -sqlAdminPassword $sqlPass -resourceTags $ResourceTags -WarningAction SilentlyContinue
-sqlAdminLogin $sqlAdmin -sqlAdminPassword $sqlPass -resourceTags $ResourceTags -enableDefaultTelemetry $EnableDefaultTelemetry -WarningAction SilentlyContinue
$deploymentSucceeded = $true
}
catch {
Expand Down
30 changes: 30 additions & 0 deletions src/optimization-engine/azuredeploy-nested.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ param recommendationsCleanUpJobId string = newGuid()

param roleContributor string = '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c'

@description('Optional. Enable telemetry to track anonymous module usage trends, monitor for bugs, and improve future releases.')
param enableDefaultTelemetry bool = true

var telemetryId = '00f120b5-2007-6120-0000-0041004f0045'
var finOpsToolkitVersion = loadTextContent('ftkver.txt')
var advisorExportsRunbookName = 'Export-AdvisorRecommendationsToBlobStorage'
var argVmExportsRunbookName = 'Export-ARGVirtualMachinesPropertiesToBlobStorage'
var argVmssExportsRunbookName = 'Export-ARGVMSSPropertiesToBlobStorage'
Expand Down Expand Up @@ -1536,6 +1541,31 @@ var automationVariables = [
}
]

//------------------------------------------------------------------------------
// Telemetry
// Used to anonymously count the number of times the template has been deployed
// and to track and fix deployment bugs to ensure the highest quality.
// No information about you or your cost data is collected.
//------------------------------------------------------------------------------

resource defaultTelemetry 'Microsoft.Resources/deployments@2022-09-01' = if (enableDefaultTelemetry) {
name: 'pid-${telemetryId}-${uniqueString(deployment().name, projectLocation)}'
properties: {
mode: 'Incremental'
template: {
'$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
contentVersion: '1.0.0.0'
metadata: {
_generator: {
name: 'FinOps toolkit'
version: finOpsToolkitVersion
}
}
resources: []
}
}
}

resource logAnalyticsWorkspace 'microsoft.operationalinsights/workspaces@2020-08-01' = if (!logAnalyticsReuse) {
name: logAnalyticsWorkspaceName
location: projectLocation
Expand Down
30 changes: 1 addition & 29 deletions src/optimization-engine/azuredeploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,6 @@ param roleReader string = '/subscriptions/${subscription().subscriptionId}/provi
@description('Optional. Enable telemetry to track anonymous module usage trends, monitor for bugs, and improve future releases.')
param enableDefaultTelemetry bool = true

var telemetryId = '00f120b5-2007-6120-0000-0041004f0045'
var finOpsToolkitVersion = loadTextContent('ftkver.txt')

//------------------------------------------------------------------------------
// Telemetry
// Used to anonymously count the number of times the template has been deployed
// and to track and fix deployment bugs to ensure the highest quality.
// No information about you or your cost data is collected.
//------------------------------------------------------------------------------

resource defaultTelemetry 'Microsoft.Resources/deployments@2022-09-01' = if (enableDefaultTelemetry) {
name: 'pid-${telemetryId}-${uniqueString(deployment().name, projectLocation)}'
location: projectLocation
properties: {
mode: 'Incremental'
template: {
'$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
contentVersion: '1.0.0.0'
metadata: {
_generator: {
name: 'FinOps toolkit'
version: finOpsToolkitVersion
}
}
resources: []
}
}
}

resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: rgName
location: projectLocation
Expand Down Expand Up @@ -90,6 +61,7 @@ module resourcesDeployment './azuredeploy-nested.bicep' = {
baseTime: baseTime
contributorRoleAssignmentGuid: contributorRoleAssignmentGuid
resourceTags: resourceTags
enableDefaultTelemetry: enableDefaultTelemetry
}
dependsOn: [
rg
Expand Down

0 comments on commit 9506f57

Please sign in to comment.