Skip to content

Instantly share code, notes, and snippets.

@bmoore-msft
bmoore-msft / New-CertificateInKeyVault
Created May 25, 2018 23:05
Create a new cert, base64 encode it and put it in KeyVault
#Requires -Module AzureRM.KeyVault
# Use this script to create a certificate that you can use to secure a Service Fabric Cluster or other VM/SSL scenario
# This script requires an existing KeyVault that is EnabledFor[Template]Deployment (property depends on the scenario)
# To create a new vault and set the EnabledForDeployment/EnabledForTemplateDeployment property run:
#
# New-AzureRmResourceGroup -Name KeyVaults -Location WestUS
# New-AzureRmKeyVault -VaultName $KeyVaultName -ResourceGroupName KeyVaults -Location WestUS -EnabledForDeployment -EnabledForTempalteDeployment
#
# Once the certificate is created and stored in the vault, the script will provide the parameter values needed for template deployment
#
#This script will call the validateMoveResources api to see if resources can be moved (before you try to actually move them)
#
$subscriptionId = '...'
$sourceResourceGroup = 'SourceGroup'
$destinationResourceGroup = 'DestGroup' #must exist
# Create an array of resourceIds that are to be moved
$resourcesToMove = @(
"/subscriptions/$subscriptionId/resourceGroups/$sourceResourceGroup/providers/Microsoft.Network/publicIPAddresses/somePublicIp"
@bmoore-msft
bmoore-msft / azuredeploy.json
Created June 27, 2017 16:16
AzureRM deployment template using listKeys on a storageAccount
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { },
"variables": {
"storeName": "[concat('store', uniqueString(resourceGroup().id))]"
},
"resources": [
{
"name": "[variables('storeName')]",
@bmoore-msft
bmoore-msft / variableNicConfigs.json
Created June 13, 2017 15:32
Deploys 2 NICs in a copyLoop with different ipConfigurations
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { },
"variables": {
"nicIPConfigurations": [
{
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets/', 'vNet', 'Subnet-1')]"
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"type": "string",
"metadata": {
"description": "Username for the Virtual Machine."
}
},
@bmoore-msft
bmoore-msft / New-KeyVaultForTemplateDeployment.ps1
Created February 22, 2016 21:40
Create an Azure KeyVault Enabled for Template Deployment (sh and ps)
#Requires -Module AzureRM.Profile
#Requires -Module AzureRM.KeyVault
#Login and Select the default subscription if needed
#Login-AzureRmAccount
#Select-AzureRmSubscription -SubscriptionName 'subscription name'
#Change the values below before running the script
$VaultName = 'myvault' #Globally Unique Name of the KeyVault
$VaultLocation = 'East US' #Location of the KeyVault