Exercise - Use the Azure portal to enable logging
Before you move customer proofs into Azure Blob Storage, you want to see how you can retrieve logging status and how to download the service log files from Azure. After downloading the log files, you would normally want to check what information is included in the log.
In this exercise, you'll check the logging status for your storage account by using PowerShell. You'll then download and review a log file.
Check logging status for Blob Storage
First, create a virtual machine scale set by using the Azure portal:
In the Azure portal, on the top toolbar, select Cloud Shell.
On the Azure Cloud Shell pane, enter the following commands:
Get-AzStorageAccount Set-AzCurrentStorageAccount -Name <StorageAccountName> -ResourceGroupName <rgn>[sandbox resource group name]</rgn> Get-AzStorageServiceLoggingProperty -ServiceType blob
<StorageAccountName>is the name of the storage account that you created in the first exercise. An example is
Notice which operations are currently logged and the log retention period. If
LoggingOperationsis set to
None, you need to enable logging. To do so, enter the following command on the Azure Cloud Shell pane:
Set-AzureStorageServiceLoggingProperty -ServiceType Blob -LoggingOperations read,write,delete -RetentionDays 5
For more information, see Azure Storage Analytics logging.
Download and install Azure Storage Explorer
Download the Azure Storage Explorer tool to download the Storage Analytics log files:
Open a new tab in your browser, and go to the Storage Explorer product page.
Ensure that you have the correct operating system selected, and then select Download Storage Explorer free.
If a pop-up dialog box appears and asks what to do with the file, select Save.
When the download is complete, open the downloaded file.
If you're prompted to approve User Account Control, select Yes.
In the Setup - Microsoft Azure Storage Explorer dialog box, select I accept the agreement > Install.
On the Select Destination Location page, select Next.
On the Select Start Menu Folder page, select Next.
On the Completing the Microsoft Azure Storage Explorer Setup Wizard page, select Finish.
Use Azure Storage Explorer to download storage log files
Open Azure Storage Explorer.
On the left-side toolbar, select the icon for Add Account.
When the Connect to Azure Storage dialog box appears:
Select Add an Azure Account > Sign in.
In the Sign in dialog box, enter your username for your Azure subscription, and then select Next.
If a page appears and prompts you to select between Work or school account and Personal account, select the appropriate option for your account.
Enter your password, and then select Sign In.
If you're prompted for a two-factor authentication (2FA) code, enter the code from your authenticator app, and then select Verify.
If a dialog box appears with the message Let Us Know What You Think, select Dismiss.
In Storage Explorer:
If you're prompted to choose an Azure subscription, make sure that you choose the subscription that you used when you created your Azure storage account, and then select Apply.
In the Explorer view, under the associated Azure subscription, expand Storage Accounts, expand the storage account that you created in the first exercise, and expand Blob Containers.
In the details pane, double-click the blob folder, double-click the folder for the current year, double-click the folder for the current month, double-click the folder for the current day, and double-click the folder for the hour.
Select one of the log files, and on the toolbar, select Open. A Notepad window should open, showing the log entries. Note that semicolons delimit each of the fields captured in an entry, and a new line denotes the next entry.
View log data in Excel (optional)
If you have Microsoft Excel, you can download and import the log data for easier analysis.
In Storage Explorer, ensure that a log file is still selected. On the toolbar, select Download.
In the Specify where to save the downloaded blob dialog box, select a location on your local computer, such as your Downloads folder. Then select Save.
Select Start > Excel.
In Excel, select Blank workbook.
In Excel, on the Data tab, select the Get Data menu, select From File, and then select From Text/CSV.
In the Import Data dialog box, in the Text Files (*.prn;*.txt;*.csv) drop-down list, select All Files (*.*).
In the Import Data dialog box, browse to the location where you downloaded the log file, such as Downloads. Select the downloaded log file, and then select Import.
In the preview window for the log file, ensure that Delimiter shows Semicolon, and that the entries appear to have columns correctly separated by field. Then select Load.
Review the log data in Excel. You can use the log format reference from the previous unit to identify which columns show which information.