Skip to content

Instantly share code, notes, and snippets.

View fabiocannas's full-sized avatar
🏠
Working from home

Fabio Cannas fabiocannas

🏠
Working from home
View GitHub Profile
@fabiocannas
fabiocannas / Get-AzureUsageCost.ps1
Last active December 5, 2022 18:16 — forked from audunsolemdal/Get-AzureUsageCost.ps1
PowerShell Script to retrieve Azure Usage and Cost/Pricing through the Usage Details API
# Licensed under the MIT license.
# Copyright (C) 2022 Helsedirektoratet
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@fabiocannas
fabiocannas / UpscaleDownscale-VM.ps1
Last active October 4, 2022 07:46
This script allows to upscale/downscale an Azure Virtual Machine. Credits to Wojciech Lepczyński (https://lepczynski.it/en/azure_en/automatic-azure-vm-resizing/). Changes: update from AzureRM to Az.
[CmdletBinding()]
param(
[Parameter(Mandatory=$True)]
[String] $VMName = "VMName",
[Parameter(Mandatory=$True)]
[String] $ResourceGroupName = "ResourceGroupName",
[Parameter(Mandatory=$True)]
[String] $Size = "VMSize"
@fabiocannas
fabiocannas / PowerBIEmbeddedScheduledAutoscaling.ps1
Last active December 2, 2022 11:06 — forked from DaveRuijter/PowerBIEmbeddedScheduledAutoscaling.ps1
PowerShell script to vertically scale up and down or pause/resume an Azure Power BI Embedded Capacity according to a schedule. You can use this in an Azure Automation Runbook.
<#
.SYNOPSIS
Vertically scale up and down or pause/resume an Azure Power BI Embedded Capacity according to a schedule using Azure Automation.
.DESCRIPTION
This Azure Automation runbook enables vertically scaling or pausing of an Azure Power BI Embedded Capacity according to a schedule. Autoscaling based on a schedule allows you to scale your solution according to predictable resource demand. For example you could require a high capacity (e.g. A5) on monday during peak hours, while the rest of the week the traffic is decreased, allowing you to scale down (e.g. A1). Outside business hours and during weekends you could then suspend the capacity so no charges will be applied. This runbook can be scheduled to run hourly. The code checks the scalingSchedule parameter to decide if scaling needs to be executed, or if the capacity is in the desired state already and no work needs to be done. The script is time zone aware.
.PARAMETER resourceGroupName
Name of the resource group to which the
@fabiocannas
fabiocannas / AzureServiceBusManager.cs
Created March 18, 2020 17:17
Here are two implementations of receiving batch messages from DeadLetterQueue of an Azure service bus entity. The second one is done by using the SubscriptionRuntimeInfo and ManagementClient classes introduced in Microsoft.Azure.ServiceBus version 4.1.1.
using System;
using System.Text;
using System.Threading.Tasks;
using AzureServiceBusExamples.Settings;
using Microsoft.Azure.ServiceBus;
using AzureServiceBusExamples.Loggers;
using System.Collections.Generic;
using Microsoft.Azure.ServiceBus.Core;
using System.Diagnostics;
using System.Linq;