Skip to content

Instantly share code, notes, and snippets.

@craig-martin
Created June 16, 2016 16:07
Show Gist options
  • Save craig-martin/45cf2dc9296ae9dd0ba1cf4a75d7cef5 to your computer and use it in GitHub Desktop.
Save craig-martin/45cf2dc9296ae9dd0ba1cf4a75d7cef5 to your computer and use it in GitHub Desktop.
<#
Script showing how to create a KeyVault vault and enable logging
(GUIDs redacted)
#>
New-AzureRmResourceGroup -Name cmartRG0614 -Location westus
<#
ResourceGroupName : cmartRG0614
Location : westus
ProvisioningState : Succeeded
Tags :
ResourceId : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cmartRG0614
#>
New-AzureRmKeyVault -VaultName cmartKV0614 -ResourceGroupName cmartRG0614 -Location westus
<#
Vault Name : cmartKV0614
Resource Group Name : cmartRG0614
Location : westus
Resource ID : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cmartRG0614/providers/Microsoft.KeyVault/vaults/cmartKV0614
Vault URI : https://cmartKV0614.vault.azure.net
Tenant ID : 00000000-0000-0000-0000-000000000000
SKU : Standard
Enabled For Deployment? : False
Enabled For Template Deployment? : False
Enabled For Disk Encryption? : False
Access Policies :
Tenant ID : 00000000-0000-0000-0000-000000000000
Object ID : 00000000-0000-0000-0000-000000000000
Application ID :
Display Name : Craig Martin ([email protected])
Permissions to Keys : get, create, delete, list, update, import, backup, restore
Permissions to Secrets : all
#>
Get-AzureRmKeyVault -VaultName cmartKV0614
<#
Vault Name : cmartKV0614
Resource Group Name : cmartRG0614
Location : westus
Resource ID : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cmartRG0614/providers/Microsoft.KeyVault/vaults/cmartKV0614
Vault URI : https://cmartkv0614.vault.azure.net/
Tenant ID : 00000000-0000-0000-0000-000000000000
SKU : Standard
Enabled For Deployment? : False
Enabled For Template Deployment? : False
Enabled For Disk Encryption? : False
Access Policies :
Tenant ID : 00000000-0000-0000-0000-000000000000
Object ID : 00000000-0000-0000-0000-000000000000
Application ID :
Display Name : Craig Martin ([email protected])
Permissions to Keys : get, create, delete, list, update, import, backup, restore
Permissions to Secrets : all
#>
New-AzureRmStorageAccount -ResourceGroupName cmartRG0614 -Name cmartsa0614 -Type Standard_LRS -Location westus
<#
ResourceGroupName : cmartrg0614
StorageAccountName : cmartsa0614
Id : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cmartrg0614/providers/Microsoft.Storage/storageAccounts/cmartsa0614
Location : westus
AccountType : StandardLRS
CreationTime : 6/16/2016 3:47:43 PM
CustomDomain :
LastGeoFailoverTime :
PrimaryEndpoints : Microsoft.Azure.Management.Storage.Models.Endpoints
PrimaryLocation : westus
ProvisioningState : Succeeded
SecondaryEndpoints :
SecondaryLocation :
StatusOfPrimary : Available
StatusOfSecondary :
Tags : {}
Context : Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext
#>
Set-AzureRmDiagnosticSetting -ResourceId '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cmartRG0614/providers/Microsoft.KeyVault/vaults/cmartKV0614' -StorageAccountId '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cmartrg0614/providers/Microsoft.Storage/storageAccounts/cmartsa0614' -Enabled $true -Categories AuditEvent
<#
StorageAccountId : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cmartrg0614/providers/Microsoft.Storage/storageAccounts/cmartsa0614
StorageAccountName :
Metrics
Logs
Enabled : True
Category : AuditEvent
#>
Get-AzureRmDiagnosticSetting -ResourceId '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/CvssTest01/providers/Microsoft.KeyVault/vaults/cmartKV0614'
<#
StorageAccountId : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cmartrg0614/providers/Microsoft.Storage/storageAccounts/cmartsa0614
StorageAccountName :
Metrics
Logs
Enabled : True
Category : AuditEvent
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment