Wednesday, October 7, 2015

Creating an Online or Offline Secondary Database using PowerShell Commands

a. To create an online Secondary Database

Start-AzureDqlDatabaseCopy -ServerName "<Secondary Server Name>"
                           -DatabaseName "<Database Name>"
                           -PartnerServer "NewServer"
                           -ContinuousCopy

b. To create an Offline Secondary Database

Start-AzureDqlDatabaseCopy -ServerName "<Secondary Server Name>"
                           -DatabaseName "<Database Name>"
                           -PartnerServer "NewServer"
                           -ContinuousCopy
                           -OfflineSecondary   

Access Storage Logs with PowerShell Commands

When Storage Logging is configured, log data is saved to blobs in the $logs container created for the storage account.

You can access logs with the Get-AzureStorageBlob command and filter logs by filename and metadata.

Get-AzureStorageBlob -Container '$logs' |
where {
    $_.Name -match 'blob/YYYY/MM/DD/HHMM' -and
    $_.ICloudBlob.Metadata.LogType -match 'write'
}
foreach {
 "{0}{1}{2}{3}" -f $_.Name,
 $_ICloudBlob.Metadata.StartTime,
 $_ICloudBlob.Metadata.EndTime,
 $_ICloudBlob.Metadata.LogType
}
           

Configuring Storage Logging and Retention using PowerShell Commands

A. To enable Storage Logging for Read, Write and Delete Actions with Retention period of 30 days,

Set-AzureStorageServiceLoggingProperty 
                    - ServiceType Blob
                    -LoggingOpertaions read,write,delete
                    -RetentionDays 30 

Set-AzureStorageServiceLoggingProperty 
                    - ServiceType Table
                    -LoggingOpertaions read,write,delete
                    -RetentionDays 30 

Set-AzureStorageServiceLoggingProperty 
                    - ServiceType Queue
                    -LoggingOpertaions read,write,delete
                    -RetentionDays 30 

B. To disable collection of metrics

Set-AzureStorageServiceLoggingProperty 
                    - ServiceType Blob
                    -LoggingOpertaions none

Set-AzureStorageServiceLoggingProperty 
                    - ServiceType Table
                    -LoggingOpertaions none

Set-AzureStorageServiceLoggingProperty 
                    - ServiceType Queue
                    -LoggingOpertaions none

Configuring Storage Metrics and Retention using PowerShell Commands


  • Azure Storage has in-built analytics feature called Azure Storage Analytics used for collecting metrics and logging storage request activity. 
  • You enable Storage Analytics Metrics to collect aggregate transactions and capacity data and you enable Storage Analytics Logging to capture Successful and Failed request attempts to your Storage Account.


There are 2 levels of metrics collections:
  1. Service Level: These metrics include aggregate statistics for all requests, aggregated at a specific interval.
  2. API Level: These metrics record every request to each service only if a request is made within the hour interval


a. To enable Service level metrics collected by minute for blobs, tables and queues with unlimited retention

Set-AzureStorageServiceMetricsProperty -MetricsType Minutes
                                       -ServiceType Blob
                                       -MetricsLevel Service
                                       -RetentionDays 0

Set-AzureStorageServiceMetricsProperty -MetricsType Minutes
                                       -ServiceType Table
                                       -MetricsLevel Service
                                       -RetentionDays 0

Set-AzureStorageServiceMetricsProperty -MetricsType Minutes
                                       -ServiceType Queue
                                       -MetricsLevel Service
                                       -RetentionDays 0

b.To enable Service and API level metrics collected by Hour for blobs, tables and queues with 90 days of retention period

Set-AzureStorageServiceMetricsProperty -MetricsType Hour
                                       -ServiceType Blob
                                       -MetricsLevel ServiceAndApi
                                       -RetentionDays 90

Set-AzureStorageServiceMetricsProperty -MetricsType Hour
                                       -ServiceType Table
                                       -MetricsLevel ServiceAndApi
                                       -RetentionDays 90

Set-AzureStorageServiceMetricsProperty -MetricsType Hour
                                       -ServiceType Queue
                                       -MetricsLevel ServiceAndApi
                                       -RetentionDays 90
C. To Disable the collection of metrics

Set-AzureStorageServiceMetricsProperty -ServiceType Blob
                                       -MetricsLevel None


Set-AzureStorageServiceMetricsProperty -ServiceType Table
                                       -MetricsLevel None


Set-AzureStorageServiceMetricsProperty -ServiceType Queue
                                       -MetricsLevel None