Skip to content

Instantly share code, notes, and snippets.

@BelRarr
BelRarr / inject-secretClient-into-controller.cs
Created November 29, 2023 15:44
inject the SecretClient into a controller
private readonly DbContext dbContext;
private readonly SecretClient secretClient;
public MyController(DbContext dbContext, SecretClient secretClient)
{
@BelRarr
BelRarr / azKV-config-proxy.cs
Created November 29, 2023 15:42
configure the proxy communication in the startup.cs file
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
var proxy = new WebProxy("http://proxyserver:8080", false);
@BelRarr
BelRarr / list-expiring-app-registrations.ps1
Created January 10, 2022 14:27
Get the list of expired or soon-to-expire azure app registrations
$daysToExpire = 30
$SoonToBeExpiredList = @()
$AlreadyExpiredList = @()
# Connect to AzureAD
Write-Output "Connecting to AzureAD..."
$connection = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzureAD -TenantId $connection.TenantID -ApplicationId $connection.ApplicationID -CertificateThumbprint $connection.CertificateThumbprint
@BelRarr
BelRarr / ServicePrincipal-CheckCredentialsExpiracy.ps1
Created October 2, 2020 17:02
Check the expiration date of your Service Principal
$sp = Get-AzADServicePrincipal -DisplayName $myServiceprincipalName
Get-AzADSpCredential -ObjectId $sp.Id
@BelRarr
BelRarr / set-CacheControlPropertyForAzureBlobStorageItem.ps1
Created June 9, 2020 15:39
Setting the CacheControl property on an Azure Blob Storage element
# Connect to Azure and position on the desired subscription
Connect-AzAccount
Get-AzSubscription -SubscriptionName "Microsoft Azure Sponsorship" | Set-AzContext
# Create a storage context
$context = New-AzStorageContext -StorageAccountName "staticwebsitestorage2" -StorageAccountKey "*****"
# Get a reference to the blob
$blob = Get-AzStorageBlob -Context $context -Container "images" -Blob "lighthouse.jfif"
@BelRarr
BelRarr / Empty-Resource-Group.ps1
Created January 3, 2020 18:28
this is the PowerShell script that deletes every resource in a given resource group. It was demonstrated in my video about Azure Automation in the Azure Advent Calendar series (https://www.youtube.com/watch?v=N1ktTy08xDs)
workflow Empty-Resource-Group
{
param(
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]
[string]
$ResourceGroupName,
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]
[String]
$SubscriptionId
)
@BelRarr
BelRarr / streaming.html
Created October 14, 2019 18:54
un site web de streaming simple
<html>
<head>
<title>Simple video streaming service</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<h1>Simple video streaming service</h1>
@BelRarr
BelRarr / clone-sql-db.ps1
Created September 26, 2019 01:25
cloner une BD Azure SQL Database via PowerShell
New-AzSqlDatabaseCopy -ResourceGroupName "RG_source" `
-ServerName "serveursource.database.windows.net" `
-DatabaseName "MaBD" `
-CopyResourceGroupName "RG_destination" `
-CopyServerName "serveurdestination.database.windows.net" `
-CopyDatabaseName "MaBdClonee"
@BelRarr
BelRarr / configure-backup-retention.ps1
Created September 3, 2019 15:38
Configurer le Backup retention pour SQL Database
# déclaration des variables
$SubscriptionId = "bd......3c"
$Location = "canadacentral"
clear-host
# connexion à Azure et positionnement sur la bonne souscription
Connect-AzureRmAccount
Set-AzureRmContext -Subscription $SubscriptionId
@BelRarr
BelRarr / install-module-azsql.ps1
Created September 3, 2019 15:32
Remove module AzureRm and install module Az.Sql
# désinstaller les modules AzureRm
Uninstall-AzureRm
# installer le module Az.Sql
Install-Module -Name Az.Sql -Force