Skip to content

Commit

Permalink
[Optimization engine] Fixes missing columns in EA savings plans expor…
Browse files Browse the repository at this point in the history
…ts (#1047)

Co-authored-by: Helder Pinto <[email protected]>
  • Loading branch information
helderpinto and Helder Pinto authored Oct 11, 2024
1 parent f1e84e1 commit 7680d0c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/_optimize/optimization-engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ The simplest, quickest and recommended method for installing AOE is by using the

1. Open Azure Cloud Shell (PowerShell)
1. Run `git clone https://github.com/microsoft/finops-toolkit.git`
1. Run `git checkout main`
1. Run `cd finops-toolkit/src/optimization-engine`
1. Run `git checkout main`
1. (optional) Run `Install-Module Microsoft.Graph.Authentication,Microsoft.Graph.Identity.DirectoryManagement` - this is required to grant the Global Reader role to the Automation Managed Identity in Microsoft Entra ID, used by Identity and RBAC governance features.
1. Run `./Deploy-AzureOptimizationEngine.ps1`
1. Input your deployment options and let the deployment finish (it will take less than 5 minutes)
Expand Down
2 changes: 1 addition & 1 deletion src/optimization-engine/azuredeploy-nested.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ var runbooks = [
}
{
name: savingsPlansExportsRunbookName
version: '1.0.1.0'
version: '1.0.2.0'
description: 'Exports Savings Plans Usage to Blob Storage using the EA or MCA APIs'
type: 'PowerShell'
scriptUri: uri(templateLocation, 'runbooks/data-collection/${savingsPlansExportsRunbookName}.ps1')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,17 @@ $savingsPlans = @()

foreach ($usage in $savingsPlansUsage)
{
$purchaseDate = $usage.properties.purchaseDateTime
if ([string]::IsNullOrEmpty($purchaseDate) -and -not([string]::IsNullOrEmpty($usage.properties.purchaseDate)))
{
$purchaseDate = (Get-Date -Date $usage.properties.purchaseDate).ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'")
}
$expiryDate = $usage.properties.expiryDateTime
if ([string]::IsNullOrEmpty($expiryDate) -and -not([string]::IsNullOrEmpty($usage.properties.expiryDate)))
{
$expiryDate = (Get-Date -Date $usage.properties.expiryDate).ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'")
}

$savingsPlanEntry = New-Object PSObject -Property @{
SavingsPlanResourceId = $usage.id
SavingsPlanOrderId = $usage.id.Substring(0,$usage.id.IndexOf("/savingsPlans/"))
Expand All @@ -188,14 +199,14 @@ foreach ($usage in $savingsPlansUsage)
ProvisioningState = $usage.properties.displayProvisioningState
AppliedScopeType = $usage.properties.userFriendlyAppliedScopeType
RenewState = $usage.properties.renew
PurchaseDate = $usage.properties.purchaseDateTime
PurchaseDate = $purchaseDate
BenefitStart = $usage.properties.benefitStartTime
ExpiryDate = $usage.properties.expiryDateTime
ExpiryDate = $expiryDate
EffectiveDate = $usage.properties.effectiveDateTime
BillingScopeId = $usage.properties.billingScopeId
BillingAccountId = $usage.properties.billingAccountId
BillingProfileId = $usage.properties.billingProfileId
BillingPlan = $usage.properties.billingProfileId
BillingPlan = $usage.properties.billingPlan
CommitmentGrain = $usage.properties.commitment.grain
CommitmentCurrencyCode = $usage.properties.commitment.currencyCode
CommitmentAmount = $usage.properties.commitment.amount
Expand Down
2 changes: 1 addition & 1 deletion src/optimization-engine/upgrade-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@
{
"runbook": {
"name": "runbooks/data-collection/Export-SavingsPlansUsageToBlobStorage.ps1",
"version": "1.0.1.0"
"version": "1.0.2.0"
},
"container": "savingsplansexports",
"requiredVariables": [
Expand Down

0 comments on commit 7680d0c

Please sign in to comment.