Skip to content

Instantly share code, notes, and snippets.

View PawelHaracz's full-sized avatar

Paweł Haracz PawelHaracz

View GitHub Profile
@PawelHaracz
PawelHaracz / login-via-pim.sh
Created March 4, 2025 16:03 — forked from paolosalvatori/login-via-pim.sh
This Bash script allows to login to a given Azure Subscription using Microsoft Entra Privileged Identity Management (PIM)
#!/bin/bash
# Variables
SUBSCRIPTION_ID=$(az account show --query id --output tsv) # Subscription ID
ROLE_NAME="8e3af657-a8ff-443c-a75c-2fe8c4bcb635" # Owner role
ROLE_DEFINITION_ID="/subscriptions/${SUBSCRIPTION_ID}/providers/Microsoft.Authorization/roleDefinitions/${ROLE_NAME}" # Role definition resource ID
PRINCIPAL_ID=$(az ad user show --id $(az account show --query user.name -o tsv) --query id -o tsv) # Your account object ID
ROLE_ASSIGNMENT_ID=$(uuidgen) # Generate a unique GUID for the role assignment
JUSTIFICATION="I need access to [$(az account show --query name --output tsv)] Azure subscription" # Justification for the role assignment
API_VERSION="2020-10-01" # API version
apiVersion: apps/v1
kind: Deployment
metadata:
name: hellofromnode-deployment
labels:
environment: dev
app: hellofromnode
spec:
replicas: 1
template:
#https://medium.com/@ferarias/docker-in-windows-11-using-wsl2-8e30faddc32c
$wslip = wsl -- ip -o -4 -json addr list eth0 | ConvertFrom-Json | %{ $_.addr_info.local } ` | ?{ $_ }
Write-Host "Setting Docker context 'wsl' to host=tcp://$($wslip):2375"
docker context update wsl --docker "host=tcp://$($wslip):2375"
docker context use wsl
using Microsoft.Extensions.Options;
using Structurizr;
using Structurizr.Api;
namespace model.c4
{
public class C4Generator
{
private readonly Options.Structurizr _options;
private const string MicroserviceTag = "Microservice";
<!DOCTYPE html>
<html lang="en">
<head>
<title>Serverless Authentication</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<!-- Latest compiled and minified CSS -->

Merry Christmas and a Happy New Year!

I hope you will finish #25daysofserverless !!

@PawelHaracz
PawelHaracz / AsyncHelper.cs
Last active June 5, 2019 10:11
the validator checks whitelist and decodes token and compare this with appId claim. An AsyncHelper invoke asynchronous method synchronously. A startup class is a normal .net core startup class
// Copyright (c) Microsoft Corporation, Inc. All rights reserved.
// Licensed under the MIT License, Version 2.0. See License.txt in the project root for license information.
/// <summary>
/// Helper created by microsoft
/// https://github.com/aspnet/AspNetIdentity/blob/master/src/Microsoft.AspNet.Identity.Core/AsyncHelper.cs
/// </summary>
public class AsyncHelper
{
@PawelHaracz
PawelHaracz / AsyncHelper.cs
Created June 5, 2019 09:35
the validator checks whitelist and decodes token and compare this with appId claim;
public class AsyncHelper
{
private static readonly TaskFactory _myTaskFactory = new TaskFactory(CancellationToken.None,
TaskCreationOptions.None, TaskContinuationOptions.None, TaskScheduler.Default);
public static TResult RunSync<TResult>(Func<Task<TResult>> func)
{
var cultureUi = CultureInfo.CurrentUICulture;
var culture = CultureInfo.CurrentCulture;
return _myTaskFactory.StartNew(() =>
Invoke-AzureRmResourceAction -ResourceGroupName <your-resource-group> -ResourceType "Microsoft.Web/sites" -ResourceName <Your-Azure-Function> -Action syncfunctiontriggers -ApiVersion "2018-02-01" -Force
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"registryPassword": {
"type": "SecureString"