Skip to content

Commit

Permalink
Improved Recommendations workbook with USD rate conversion for some A…
Browse files Browse the repository at this point in the history
…dvisor cost recommendations

Improved Recommendations workbook with USD rate conversion for some Advisor cost recommendations
  • Loading branch information
helderpinto authored Apr 12, 2024
2 parents c349b99 + 7f3d703 commit 801867b
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 16 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/cleanup-dev-new.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: AOE Clean Up (DEV NEW)
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # This will run the action every day at midnight
permissions:
id-token: write
contents: read
jobs:
AOE-CLEANUP:
environment: devnew
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev'

steps:
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref }} branch of the ${{ github.repository }} repository!"
- name: Installing modules
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name Az.Accounts,Az.Resources -Force
- name: Check out repository code
uses: actions/checkout@v3
- name: Login via Az module
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
- name: Testing PowerShell script call
shell: pwsh
run: |
$aoeResource = Get-AzResource -Id "/subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ secrets.AOE_NAMEPREFIX }}-rg/providers/Microsoft.Automation/automationAccounts/${{ secrets.AOE_NAMEPREFIX }}-auto" -ExpandProperties
if ((Get-Date) -gt $aoeResource.Properties.creationTime.AddDays(${{ vars.AOE_MAXAGEDAYS }})) { Write-Host "Deleting Resource Group"; Remove-AzResourceGroup -Name "${{ secrets.AOE_NAMEPREFIX }}-rg" -Force -AsJob } else { Write-Host "Resource Group is not old enough to delete" }
- run: echo "🍏 This job's status is ${{ job.status }}."
52 changes: 52 additions & 0 deletions .github/workflows/continuous-deployment-dev-new.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: AOE Continuous Deployment (DEV NEW)
on:
workflow_dispatch:
push:
branches:
- dev
permissions:
id-token: write
contents: read
jobs:
AOE-CD:
environment: devnew
runs-on: ubuntu-latest
env:
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AOE_SQL_ADMIN: ${{ secrets.AOE_SQL_ADMIN }}
AOE_SQL_PASSWD: ${{ secrets.AOE_SQL_PASSWD }}
AOE_LOCATION: ${{ secrets.AOE_LOCATION }}
AOE_NAMEPREFIX: ${{ secrets.AOE_NAMEPREFIX }}
steps:
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref }} branch of the ${{ github.repository }} repository!"
- name: Installing modules
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name Az.Accounts,Az.Resources,Az.Storage,Az.OperationalInsights,Az.Sql,Az.Automation,Microsoft.Graph.Authentication,Microsoft.Graph.Identity.DirectoryManagement -Force
- name: Check out repository code
uses: actions/checkout@v3
- name: Login via Az module
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
- name: Create Deployment Settings JSON file
run: |
echo '{
"SubscriptionId": "'"$AZURE_SUBSCRIPTION_ID"'",
"NamePrefix": "'"$AOE_NAMEPREFIX$(date '+%Y%m%d%H')"'",
"WorkspaceReuse": "n",
"DeployWorkbooks": "y",
"SqlAdmin": "'"$AOE_SQL_ADMIN"'",
"SqlPass": "'"$AOE_SQL_PASSWD"'",
"TargetLocation": "'"$AOE_LOCATION"'",
"DeployBenefitsUsageDependencies": "n"
}' > ./deploymentSettings.json
- name: Testing PowerShell script call
shell: pwsh
run: |
./Deploy-AzureOptimizationEngine.ps1 -SilentDeploymentSettingsPath ./deploymentSettings.json -TemplateUri "https://raw.githubusercontent.com/helderpinto/AzureOptimizationEngine/dev/azuredeploy.bicep"
- run: echo "🍏 This job's status is ${{ job.status }}."
56 changes: 56 additions & 0 deletions .github/workflows/continuous-deployment-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: AOE Continuous Deployment (DEV)
on:
workflow_dispatch:
push:
branches:
- dev
permissions:
id-token: write
contents: read
jobs:
AOE-CD:
environment: dev
runs-on: ubuntu-latest
env:
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AOE_SQL_ADMIN: ${{ secrets.AOE_SQL_ADMIN }}
AOE_SQL_PASSWD: ${{ secrets.AOE_SQL_PASSWD }}
AOE_LOCATION: ${{ secrets.AOE_LOCATION }}
AOE_NAMEPREFIX: ${{ secrets.AOE_NAMEPREFIX }}
AOE_WORKSPACENAME: ${{ secrets.AOE_WORKSPACENAME }}
AOE_WORKSPACERG: ${{ secrets.AOE_WORKSPACERG }}
steps:
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref }} branch of the ${{ github.repository }} repository!"
- name: Installing modules
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name Az.Accounts,Az.Resources,Az.Storage,Az.OperationalInsights,Az.Sql,Az.Automation,Microsoft.Graph.Authentication,Microsoft.Graph.Identity.DirectoryManagement -Force
- name: Check out repository code
uses: actions/checkout@v3
- name: Login via Az module
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
- name: Create Deployment Settings JSON file
run: |
echo '{
"SubscriptionId": "'"$AZURE_SUBSCRIPTION_ID"'",
"NamePrefix": "'"$AOE_NAMEPREFIX"'",
"WorkspaceReuse": "y",
"WorkspaceName": "'"$AOE_WORKSPACENAME"'",
"WorkspaceResourceGroupName": "'"$AOE_WORKSPACERG"'",
"DeployWorkbooks": "y",
"SqlAdmin": "'"$AOE_SQL_ADMIN"'",
"SqlPass": "'"$AOE_SQL_PASSWD"'",
"TargetLocation": "'"$AOE_LOCATION"'",
"DeployBenefitsUsageDependencies": "n"
}' > ./deploymentSettings.json
- name: Testing PowerShell script call
shell: pwsh
run: |
./Deploy-AzureOptimizationEngine.ps1 -SilentDeploymentSettingsPath ./deploymentSettings.json -TemplateUri "https://raw.githubusercontent.com/helderpinto/AzureOptimizationEngine/dev/azuredeploy.bicep" -DoPartialUpgrade
- run: echo "🍏 This job's status is ${{ job.status }}."
6 changes: 4 additions & 2 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AOE_SQL_ADMIN: ${{ secrets.AOE_SQL_ADMIN }}
AOE_SQL_PASSWD: ${{ secrets.AOE_SQL_PASSWD }}
AOE_LOCATION: ${{ secrets.AOE_LOCATION }}
AOE_NAMEPREFIX: ${{ secrets.AOE_NAMEPREFIX }}
steps:
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref }} branch of the ${{ github.repository }} repository!"
- name: Installing modules
Expand All @@ -35,12 +37,12 @@ jobs:
run: |
echo '{
"SubscriptionId": "'"$AZURE_SUBSCRIPTION_ID"'",
"NamePrefix": "aoeprdgithub",
"NamePrefix": "'"$AOE_NAMEPREFIX"'",
"WorkspaceReuse": "n",
"DeployWorkbooks": "y",
"SqlAdmin": "'"$AOE_SQL_ADMIN"'",
"SqlPass": "'"$AOE_SQL_PASSWD"'",
"TargetLocation": "westeurope",
"TargetLocation": "'"$AOE_LOCATION"'",
"DeployBenefitsUsageDependencies": "n"
}' > ./deploymentSettings.json
- name: Testing PowerShell script call
Expand Down
11 changes: 8 additions & 3 deletions Deploy-AzureOptimizationEngine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,13 @@ if (-not($deploymentOptions["ResourceGroupName"]))
$resourceGroupName = $resourceGroupNameTemplate -f $namePrefix
$storageAccountName = $storageAccountNameTemplate -f $namePrefix
$automationAccountName = $automationAccountNameTemplate -f $namePrefix
$sqlServerName = $sqlServerNameTemplate -f $namePrefix
$laWorkspaceName = $laWorkspaceNameTemplate -f $namePrefix
$sqlServerName = $sqlServerNameTemplate -f $namePrefix
if ("Y", "y" -contains $workspaceReuse -and $silentDeploy) {
$laWorkspaceName = $deploymentOptions["WorkspaceName"]
}
else {
$laWorkspaceName = $laWorkspaceNameTemplate -f $namePrefix
}
$sqlDatabaseName = "azureoptimization"
}

Expand All @@ -393,7 +398,7 @@ if (-not($deploymentOptions["ResourceGroupName"]))
else
{
# With a silent deploy, overrule any custom resource naming if a NamePrefix is provided
if($silentDeploy -and (![string]::IsNullOrEmpty($namePrefix)))
if($silentDeploy -and ![string]::IsNullOrEmpty($namePrefix) -and $namePrefix -ne "EmptyNamePrefix")
{
$deploymentName = $deploymentNameTemplate -f $namePrefix
$resourceGroupName = $resourceGroupNameTemplate -f $namePrefix
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,4 +446,4 @@ The Reservations Usage Workbook has a couple of "Unused Reservations" tiles that

* **Why is AOE recommending to delete a long-deallocated VM that was already deleted?** Due to the fact that Azure consumption exports are collected with a (default) offset of 7 days, the _LongDeallocatedVms_ recommendation might recommend for deletion a long-deallocated VM that was meanwhile deleted. That false positive should normally disappear in the next iteration.

* **How much does running AOE in my subscription cost?** The default AOE deployment requires cheap Azure resources: an Azure Automation account, an Azure SQL Database and a Storage Account. The costs will depend on the size of your environment, but even in customers with thousands of VMs, the costs do not amount to more than 50 EUR/month. In small to medium-sized environments, it will cost less than 20 EUR/month. **These costs do not include VM performance metrics ingestion into Log Analytics**.
* **How much does running AOE in my subscription cost?** The default AOE deployment requires cheap Azure resources: an Azure Automation account, a small Azure SQL Database and a Storage Account. It also requires a Log Analytics Workspace to which it sends all the logs used by Workbooks. The costs, mostly coming from Azure Automation, depend on the size of your environment, but even in customers with hundreds of VMs, AOE costs do not amount to more than 100 EUR/month. In small to medium-sized environments, it will cost less than 20 EUR/month. **These costs do not include agent-based VM performance metrics ingestion into Log Analytics**.
2 changes: 1 addition & 1 deletion views/workbooks/benefits-simulation.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
{
"type": 1,
"content": {
"json": "If below tabs are reporting query errors, you must set up Pricesheet exports. See more details [here](https://github.com/helderpinto/AzureOptimizationEngine#enabling-the-reservations-and-benefits-usage-workbooks).",
"json": "If below tabs are reporting query errors, you must set up Pricesheet exports. See more details [here](https://aka.ms/AzureOptimizationEngine/commitmentssetup).",
"style": "warning"
},
"name": "text - 6"
Expand Down
2 changes: 1 addition & 1 deletion views/workbooks/benefits-usage.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
{
"type": 1,
"content": {
"json": "If below tabs are reporting query errors, you must set up Pricesheet exports. See more details [here](https://github.com/helderpinto/AzureOptimizationEngine#enabling-the-reservations-and-benefits-usage-workbooks).",
"json": "If below tabs are reporting query errors, you must set up Pricesheet exports. See more details [here](https://aka.ms/AzureOptimizationEngine/commitmentssetup).",
"style": "warning"
},
"name": "text - 8"
Expand Down
2 changes: 1 addition & 1 deletion views/workbooks/identities-roles.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{
"type": 1,
"content": {
"json": "For full functionality, this workbook requires Microsoft Entra ID exports. If you had not assigned the Global Reader role to the AOE managed identity yet, please do so ([see requirements](https://github.com/helderpinto/AzureOptimizationEngine#requirements)).",
"json": "For full functionality, this workbook requires Microsoft Entra ID exports. If you had not assigned the Global Reader role to the AOE managed identity yet, please do so ([see requirements](https://aka.ms/AzureOptimizationEngine/requirements)).",
"style": "info"
},
"name": "text - 22"
Expand Down
Loading

0 comments on commit 801867b

Please sign in to comment.