Tuesday, May 10, 2016

Powershell Commands to stream Website Diagonistic Logs

Get-WebsiteLog - Name "MySite" -Tail

Deploying and Managing Azure Websites with Powershell Commands

Extract from : MSDN

Name Description
Get-AzureWebsiteGets information about websites in Azure associated with the current subscription.
Get-AzureWebsiteDeploymentGets the deployments for a website in Azure.
Get-AzureWebsiteLocationGets all available website locations.
New-AzureWebsiteCreate a new website to run in Azure.
Remove-AzureWebsiteRemoves the specified website from Azure.
Restart-AzureWebsiteStops and then restarts the specified website.
Restore-AzureWebsiteDeploymentRedeploys a previous deployment of a website in Azure.
Save-AzureWebsiteLogDownloads and saves the logs for a specified website.
Set-AzureWebsiteConfigures a website running in Azure.
Show-AzurePortalShow the Azure Management Portal.
Show-AzureWebsiteOpens a browser on a specified website.
Start-AzureWebsiteStarts the specified website.
Stop-AzureWebsiteStops the specified website.

Powershell commands for Deployment slots

1. Powershell commands to set 2 app settings "Sticky to a Slot":

SET-AzureWebsite -Name "mySite" -SlotStickyAppSettingsName @("mySlot", "mySlot2")

2. Powershell Command for Autoswap between Staging and Production Slot:

 SET- AzureWebsite -Name "mySite" -SlotStaging - AutoSwapSlotName Production

3. Poweshell Command to set 2 connection strings as "Sticky to a Slot":

Set-AzureWebsite -Name "mySite" -SlotStickyConnectionStringName @("myConn","MyConn2")

Saturday, October 10, 2015

Moving a VM to a new Subnet using Powershell Commands

You can move a VM to a new subnet with the management portal or Windows PowerShell Commands

Get-AzureVM -ServiceName "<CloudServiceName>"
            -Name "<VMName>"
Set-AzureSubnet -SubnetName "<SubnetName>"
Update-AzureVM

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