Skip to content

Instantly share code, notes, and snippets.

View ljtill's full-sized avatar
🔨

Lyon Till ljtill

🔨
View GitHub Profile
@ljtill
ljtill / recovery-services.json
Last active December 6, 2019 15:41
Provides the ability to provision Azure Recovery Services vaults via templates
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vaultName": {
"type": "string",
"metadata": {
"description": "Name of the Vault"
}
},
@ljtill
ljtill / AzureRmStorage.ps1
Last active December 6, 2019 15:35
Provides the ability to validate Storage Encryption status
$StorageAccountKeys = Get-AzureRmStorageAccountKey -ResourceGroupName "" -Name ""
$StorageContext = New-AzureStorageContext -StorageAccountName "" -StorageAccountKey $StorageAccountKeys[0].Value
$StorageBlob = Get-AzureStorageBlob -Blob "" -Container "" -Context $StorageContext
$StorageBlob.ICloudBlob.Properties.IsServerEncrypted
@ljtill
ljtill / Dockerfile
Last active December 6, 2019 16:14
Provides the ability to create Docker images for PowerShell / .NET
FROM ubuntu:latest AS build
# Environment variable
ENV DEBIAN_FRONTEND noninteractive
## PowerShell
# Update the list of products
RUN apt-get update
@ljtill
ljtill / Repositories.ps1
Last active December 6, 2019 16:31
Provides the ability to clone all Azure DevOps repositories
function Invoke-AzureDevOpsRepositoriesClone {
[CmdletBinding()]
param (
[Parameter()]
[string]$AccountName,
[Parameter()]
[string]$ProjectName,
@ljtill
ljtill / AzureRmStorage.ps1
Last active October 4, 2018 21:56
Provides the ability to report on Storage Account access
function Get-AzureRmStoragePublicAccess {
[CmdletBinding()]
param ()
begin {
$subscriptions = Get-AzureRmSubscription | Out-GridView -Title "Microsoft Azure - Subscriptions" -PassThru
}
process {
@ljtill
ljtill / Environment.cs
Last active December 6, 2019 16:13
Provides the ability to retrieve an environment variable
private static string GetEnvironment(string name)
{
/// <summary>
/// Environment Variable retrieval from AppSettings or local.settings.json
/// </summary>
return Environment.GetEnvironmentVariable(name, EnvironmentVariableTarget.Process);
}
@ljtill
ljtill / Secret.cs
Last active December 6, 2019 16:10
Provides the ability to retrieve a secret from Key Vault
private static async Task<string> GetSecret(string uri, string name)
{
/// <summary>
/// Secret retrieval via Managed Service Identity (MSI).
/// Link: https://docs.microsoft.com/en-us/azure/active-directory/managed-service-identity/overview
/// </summary>
AzureServiceTokenProvider provider = new AzureServiceTokenProvider();
KeyVaultClient client = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(provider.KeyVaultTokenCallback));
SecretBundle secret = await client.GetSecretAsync((uri + $"/Secrets/{name}"));
string value = secret.Value;
@ljtill
ljtill / AzureRmAccessToken.ps1
Last active October 4, 2018 21:56
Provides the ability to retrieve the Access Token from the current Context
function Get-AzureRmAccessToken {
<#
.SYNOPSIS
Get-AzureRmAccessToken will retrieve the Access Token from the current AzureRm context.
.DESCRIPTION
Provides the ability to retrieve the current authenticated Access Token within the AzureRm.Profile context.
Returns the Access Token to allow for interaction directly with Microsoft Azure REST API's.
.EXAMPLE
Get-AzureRmAccessToken
@ljtill
ljtill / AzureRmContext.ps1
Last active October 4, 2018 21:56
Provides the ability to validate the current session context
function Get-AzureRmContext {
<#
.SYNOPSIS
Get-AzureRmContext will validate the current AzureRm session.
.DESCRIPTION
Validates that the current session is authenticated, if not then it will initiate Add-AzureRmAccount.
.EXAMPLE
Get-AzureRmContext
#>
@ljtill
ljtill / AzureRmAccessToken.ps1
Last active October 4, 2018 21:56
Provides the ability to retrieve an access token from an Azure AD Application
function Get-AzureRmAccessToken {
<#
.SYNOPSIS
Get-AzureRmAccessToken will retrieve an Access Token via Azure Active Directory.
.DESCRIPTION
Provides the ability to retrieve an Access Token from Azure Active Directory Application.
.EXAMPLE
Get-AzureRmAccessToken -TenantId $tenantId -ClientId $clientId -ClientSecret $clientSecret
.LINK