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 / gist:7be34a0f11a7d0445fb30d58609fc360
Created October 3, 2024 10:21
Allow filezilla user to connect via FTP to Azure Fileshare mount on Azure Win VM
runas /user:filezilla cmd.exe
cmdkey /add:{storage-account}.file.core.windows.net /user:{storage-account} /pass:{account-key}
@fabiocannas
fabiocannas / gist:15a5ccc46e0ccbfbcc403fce43536028
Created August 26, 2024 10:33
How to create an App Registration on EntraID and use it to get the authentication token needed to call the Azure Management Rest APIs
• Create an app registration on EntraID > App registrations;
• Take note of the client ID and the Azure tenant id;
These IDs can be retrieved from the overview section of the app registration;
• Create a secret: from the “Certificates and secrets” > new client secret section. Take note of the secret value and store it safely;
• From the “Api Permissions” section add the following permission:
Azure Service Management > user_impersonation
• Assign the necessary RBAC roles.
@fabiocannas
fabiocannas / generateServiceBusQueueSASToken.ps1
Created August 7, 2024 13:10
Creation of a Service Bus Queue SAS Token
[Reflection.Assembly]::LoadWithPartialName("System.Web")| out-null
$URI="<sb_namespace_uri>/<queue_name>"
$Access_Policy_Name="<access_policy_name>"
$Access_Policy_Key="<access_policy_key>"
$targetDate = [DateTime]::ParseExact("<date_dd/MM/yyyy>", "dd/MM/yyyy", $null).Date.AddHours(23).AddMinutes(59).AddSeconds(59).AddMilliseconds(999)
# Convert the target date to Unix timestamp
$Expires= [DateTimeOffset]::new($targetDate).ToUnixTimeSeconds()
$SignatureString=[System.Web.HttpUtility]::UrlEncode($URI)+ "`n" + [string]$Expires
$HMAC = New-Object System.Security.Cryptography.HMACSHA256
@fabiocannas
fabiocannas / PowerBIEmbeddedScheduledAutoscaling.ps1
Last active July 24, 2024 14:20 — 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 / SSL-renewal.md
Last active July 17, 2024 14:12 — forked from EmadAdly/SSL-renewal.md
Renew The Let’s Encrypt Certificate in bitnami

Renew The Let’s Encrypt Certificate

Let’s Encrypt certificates are only valid for 90 days. To renew the certificate before it expires, run the following commands from the server console as the bitnami user. Remember to replace the DOMAIN placeholder with your actual domain name, and the EMAIL-ADDRESS placeholder with your email address.

1- Login your server using SSH

ssh -i Key.pem [email protected]

2- Stop Apache Server

sudo /opt/bitnami/ctlscript.sh stop

@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 / 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;