Skip to content

Instantly share code, notes, and snippets.

@maskati
maskati / #bicep-rest-http-client.md
Created December 4, 2024 12:48
Call REST APIs in Azure Bicep templates without deployment scripts

Did you know you can call REST APIs from your Bicep deployment templates using just a function call?

var getResponse = httpClient.listHttpRequest(httpClient.apiVersion, {
  method: 'GET'
  uri: 'https://mallow.fi/'
})

var postResponse = httpClient.listHttpRequest(httpClient.apiVersion, {
 method: 'POST'
@maskati
maskati / deployment-gantt.md
Last active December 16, 2024 09:27
Create a Mermaid gantt chart of your Azure deployment operations

You can create a Mermaid Gantt Chart in order to visualize the sequence and duration of Azure deployment operations. The output is similar to the following:

gantt
  dateFormat %YYYY-%m-%dT%H:%M:%S.%L%Z
  axisFormat %H:%M:%S.%L
  title Deployment 'mydeployment'
  > : milestone, 2024-12-09T14:00:14.1519943Z, 0ms
  x : milestone, 2024-12-09T14:00:23.5689337Z, 0ms
  section mydeployment
@maskati
maskati / #azure-privileged-containers.md
Created December 11, 2024 11:55
Using Blobfuse2 to mount Azure Blob Storage using managed identity from Azure Container Instance privileged containers

Using Blobfuse2 to mount Azure Blob Storage using managed identity from Azure Container Instance privileged containers

@maskati
maskati / #azure-powershell-uniquestring.md
Last active January 2, 2025 08:37
Calculating the Bicep `uniqueString` hash locally using PowerShell

Calculating the Bicep uniqueString hash locally using PowerShell

The Bicep uniqueString as well as the ARM uniqueString function:

Creates a deterministic hash string based on the values provided as parameters

The actual function implementation is not documented, but is (almost certainly) a variant of the Murmur hash algorithm that maps the provided string parameters to a 64 bit hash and returns a 13 character Base32-like encoding of this hash.

The function:

  1. Concatenates the string parameters with a dash -
  2. UTF8 encodes the resulting concatenated string
@maskati
maskati / #servicebusemulator.md
Last active January 9, 2025 07:07
Service Bus Emulator on Azure Container Instance

Service Bus Emulator on Azure Container Instance

Deploys within an Azure Container Instance container group with Azure Service Bus Emulator and Azure SQL Edge.

Configures the emulator using Config.json.

You must accept the Service Bus Emulator EULA and Azure SQL Edge EULA.

Service Bus TCP 5672 is open to the internet without authentication. Parameter exposeMssqlPort defines if the MSSQL default port is open to the internet authenticated with mssqlSaPassword which is by default S3rv1c3Bu$Emul@t0r.

@maskati
maskati / #powershell-xml-bom.md
Last active January 9, 2025 07:06
PowerShell XML with and without BOM

PowerShell XML with and without BOM

# ok, returns XmlDocument
Invoke-RestMethod 'https://gist.githubusercontent.com/maskati/69324c8232cc93914b65b8b300a60dc5/raw/a082827c9cb6faacd9f89a5c803d91daef3d1b3e/nobom.xml'

# ok, conversion to XmlDocument fails and returns string with initial BOM character (0xFEFF) UTF8 encoded as 0xEF 0xBB 0xBF
Invoke-RestMethod 'https://gist.githubusercontent.com/maskati/69324c8232cc93914b65b8b300a60dc5/raw/a082827c9cb6faacd9f89a5c803d91daef3d1b3e/bom.xml'

# fails because XmlDocument.LoadXml cannot handle initial BOM character
@maskati
maskati / #entra-id-principals-permissions-report.md
Last active June 18, 2025 09:28
Generate a report of Entra ID principals and permissions

Generate a report of Entra ID principals and permissions

I wanted a way to report on current Entra ID principals in my tenant as well as the permissions granted to such principals across apps, the tenant directory and Azure subscriptions. Microsoft provides the separately licensed Entra Permissions Management which provides comprehensive principal and permissions discovery and reporting. I wanted something simpler.

The PowerShell script entra-id-principals-permissions-report.ps1 enumerates all principals and various permissions available in your current [Azure CLI login context](https://learn.microsoft.com/en-us/cli/azure/a

@maskati
maskati / #flexible-federated-identity.md
Created January 16, 2025 08:50
Azure flexible federated identity credentials

Azure flexible federated identity credentials

Up until now you have been able to define a federatedIdentityCredential with the issuer, audiences and subject properties. For example to allow a GitHub Actions workflow running in the context of environment prod in the repository octo-org/octo-repo:

{
  "issuer": "https://token.actions.githubusercontent.com"
  "audiences": [
    "api://AzureADTokenExchange"
  ]
@maskati
maskati / #azure-vpn.md
Last active October 28, 2025 06:53
Host your own global VPN on Azure PaaS using Tailscale

Host your own global VPN on Azure PaaS using Tailscale

This example shows setting up a Tailscale exit node running as a container on Azure Container Instances to provide global Internet egress. You can also use a similar setup to configure a Tailscale subnet router which would allow access to Azure private Virtual Networks, private endpoints, private DNS zone resolution as well as Azure service endpoints.

You can use exit nodes on several platforms including Android, iOS, Linux, macOS, tvOS and Windows.

Warning

Using an exit node will tunnel all your traffic through the selected Azure region. This might trigger certain security controls such as Entra ID protection impossible travel.

[!NOTE]

@maskati
maskati / #keyvault-copy-across-subscriptions.md
Created February 6, 2025 07:01
Copy Azure Key Vault keys between subscriptions

Copy Azure Key Vault keys between subscriptions

Azure Key Vault keys secure the private key material in a way that is not exportable. Key Vault backups are encrypted and restricted to the same Azure subscription and Azure geography.

You can copy a key from one subscription to another by:

  1. Taking a backup in the source subscription
  2. Creating a new key vault in the source subscription (any region in the same geography) and restoring the backup
  3. Moving the new key vault to the destination subscription

Some limitations: