Skip to content

Instantly share code, notes, and snippets.

View jamesbannan's full-sized avatar

James Bannan jamesbannan

View GitHub Profile
@jamesbannan
jamesbannan / getBillingData.ps1
Created June 17, 2020 00:24
Azure Billing and Usage Data scripts
# Licensed under the MIT license.
# Copyright (C) 2017 Kristofer Liljeblad
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@jamesbannan
jamesbannan / nearestAzureRegion.ps1
Created May 8, 2018 03:47
Find nearest Azure region based on IP address
# Get all Azure regions accessible with my subscription
$regions = az account list-locations | ConvertFrom-Json
$locations = $regions | Select-Object displayName,latitude,longitude | Sort-Object displayName
# Get my location based on IP address
$request = (Invoke-WebRequest -Uri http://ip-api.com/json).Content | ConvertFrom-Json
$latitude = $request.lat
$longitude = $request.lon
$hash = [ordered]@{
@jamesbannan
jamesbannan / azureRegionCountry.ps1
Last active May 8, 2018 22:56
Get all Azure regions in the same country based on IP address
# Get all Azure regions accessible with my subscription
$regions = az account list-locations | ConvertFrom-Json
$locations = $regions | Select-Object displayName,latitude,longitude | Sort-Object displayName
# Get my location based on IP address
$request = (Invoke-WebRequest -Uri http://ip-api.com/json).Content | ConvertFrom-Json
$latitude = $request.lat
$longitude = $request.lon
$countryCode = $request.countryCode
"chefValidationKey": {
"reference": {
"keyVault": {
"id": "/subscriptions/<SUBSCRIPTIONID>/resourceGroups/<RESOURCEGROUPNAME>/providers/Microsoft.KeyVault/vaults/<VAULTNAME>"
},
"secretName": "chef-org-validator"
}
}
## Log in to Azure Resource Manager
Add-AzureRmAccount
## Create Resource Group
$resourceGroupName = 'keyvault'
$location = 'Australia Southeast'
$resourceGroup = New-AzureRmResourceGroup `
-Name $resourceGroupName `