Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Grote JustinGrote

View GitHub Profile
@JustinGrote
JustinGrote / Set-AzBicepTemplateSpec
Created Jul 15, 2021
Use Bicep to define a template spec
View Set-AzBicepTemplateSpec
#requires -version 7
function Set-AzBicepTemplateSpec {
[CmdletBinding()]
param(
#Template spec Resource ID to set
[Alias('Id')][Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)]$ResourceId,
#Path to the bicep file
[Parameter(Mandatory)][String]$Path,
#Optional Path to the UI Definition
[String]$UIDefinitionPath = $($Path -replace '.bicep$','.ui.json'),
@JustinGrote
JustinGrote / Set-MgM365CreatorGroup.ps1
Created Jul 8, 2021
Restrict Microsoft 365 Groups (and Teams) creation to a specified group of approved creators
View Set-MgM365CreatorGroup.ps1
#requires -module Microsoft.Graph.Identity.DirectoryManagement
using namespace Microsoft.Graph.PowerShell.Models
function Set-MgM365CreatorGroup {
<#
.SYNOPSIS
Assigns a group whos members can create Microsoft 365 Groups used for Teams, Sharepoint, etc.
.DESCRIPTION
This will restrict creation of Microsoft 365 Groups to only the members of this group and certain admin roles.
.NOTES
The members MUST have Azure AD Premium licenses assigned in order to create groups.
@JustinGrote
JustinGrote / Get-AzTenantId.ps1
Created Jul 8, 2021
Get Azure Tenant ID from Name
View Get-AzTenantId.ps1
function Get-AzTenantId {
<#
.SYNOPSIS
Resolves the tenant ID for a specified name.
.OUTPUTS
System.Guid. The Tenant ID of the specified name
#>
[CmdletBinding()]
param(
#The tenant string you wish to resolve. Examples include: mydomain.com, myorg.onmicrosoft.com
@JustinGrote
JustinGrote / openGithubInRemoteRepo.ts
Created Jun 30, 2021
Tampermonkey script to add a "Open in Remote Repositories" button
View openGithubInRemoteRepo.ts
// ==UserScript==
// @name GitHub in VSCode Remote Repository
// @version 0.0.1
// @description A userscript that adds a button to open a repo in VSCode using github1s
// @license MIT
// @author Justin Grote (Heavily borrowed from Rob Garrison)
// @namespace https://github.com/JustinGrote
// @include https://github.com/*
// @run-at document-end
// @grant none
@JustinGrote
JustinGrote / Get-AzTagEntry.ps1
Created May 20, 2021
Get Tags for Azure Resources in a more Export-Friendly Format
View Get-AzTagEntry.ps1
function Get-AzTagEntry {
<#
.SYNOPSIS
Fetches the tags for a resource as simple objects
.EXAMPLE
Get-AzVM | Get-AzTagEntry
#>
[CmdletBinding()]
param(
[Parameter(ValueFromPipelineByPropertyName)][String]$Id
@JustinGrote
JustinGrote / settings.json
Created Apr 28, 2021
ErrorLens Customization recommendations
View settings.json
"workbench.colorCustomizations": {
"errorLens.errorBackground": "#e4545410",
"errorLens.errorForeground": "#ff646440",
"errorLens.errorMessageBackground": "#e4545405",
"errorLens.warningBackground": "#ff942f10",
"errorLens.warningForeground": "#fa973a70",
"errorLens.warningMessageBackground": "#fff00005"
}
"errorLens.annotationPrefix": [
"💥 ",
@JustinGrote
JustinGrote / run.ps1
Created Apr 14, 2021
Azure Function Powershell to fetch users from a customer tenant via Microsoft Graph
View run.ps1
using namespace System.Net
# Input bindings are passed in via param block.
[CmdletBinding()]
param(
[HttpRequestContext]$Request,
[HashTable]$TriggerMetadata
)
$ErrorActionPreference = 'Stop'
@JustinGrote
JustinGrote / settings.json
Created Mar 25, 2021
Custom Gitmoji Config
View settings.json
"gitmoji.onlyUseAdditionalEmojis": true,
"gitmoji.additionalEmojis": [
{
"emoji": "",
"code": "feat: ",
"description": "Add a new feature [minor]"
},
{
"emoji": "🐛",
"code": "fix: ",
@JustinGrote
JustinGrote / ValheimPlusInstall.ps1
Last active Mar 6, 2021
Valheim Installation Scripts
View ValheimPlusInstall.ps1
param (
#Path to the valheim root directory, for case of using an alternate installation such as a server
[String]$Path,
#Name of the release if you want to download a specific version e.g. 0.9.3
[String]$Release
)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ErrorActionPreference = 'Stop'
#region Helpers
function get-SteamInstallPath {
View AzureNamingConvention.md

Key Principles

  1. Assuming we are doing ARM, everything in Azure is a typed reference, its impossible to create a conflict by naming two different typed items the same, e.g. a 'test' vritual machine and a 'test' storage account are different resources and are always referenced separately by their fully qualified type names
  2. Tags are where metadata about an object should be. THe objects name itself should be short or random, but the tags are where the real parsing/filtering/search need to occur by department, etc.
  3. A name in Azure is typically immutable, so it should not contain mutable properties, e.g. server environments can change, regions can change, etc.
  4. DNS conflicts in the customer DNS zone are a potential source however DNS is mutable and aliases can be created, and there are very few object types that share Azure dns namespaces. The original alias remains clean.
  5. While multiregion deployments are common, most
  6. An organization prefix is essential to minimize conflicts after organizational