- Access Azure using Visual Studio's Cloud Explorer
- Basics about Shared Access Signatures
- Use PowerShell to administrate Azure
-
Open Azure Portal and sign in.
-
Discussion points:
- If some attendees are completely new to Azure, demonstrate the features of the portal
- Talk about security aspects of Azure administration
-
Create a new Resource group named
PracticalDevOps-Dev
-
Discussion points:
- Describe the importance of resource groups
- Talk about RBAC and resource groups
-
Add a Storage account named
books<yourname>dev
(replace<yourname>
with your name to get a globally unique storage account name).
-
Discussion points:
- Brief overview about different storage offerings in Azure (PaaS, IaaS)
- Short introduction into the features of blob storage (access via HTTPS, redunancy options, account name/key, private vs. public containers, etc.)
-
Use Cloud Explorer in Visual Studio to connect to your storage account.
-
Use Cloud Explorer to create a new Blob Container named
booknametokens
. -
Upload BookNameTokens.txt into the new container.
-
Try to open blob using a browser. It must not work as the blob is private!
-
Open PowerShell with Azure PowerShell installed.
-
Discussion points:
- PowerShell vs. Azure CLI
-
Use the following script to create a Shared Access Signature (SAS) for the uploaded blob (note that you have to replace
<yourname>
accordingly). If you want, experiment with the Azure PowerShell commands.# Set various names $resourceGroupName = "PracticalDevOps-Dev" $storageAccountName = "books<yourname>dev" $containerName = "booknametokens" $policyName = "BookNameTokens Policy 2" # Sign-in Login-AzureRmAccount # Optionally: If you have mulitple subscriptions, select the one you want to use # Get-AzureRmSubscription # Select-AzureRmSubscription -SubscriptionId ... $accountKeys = Get-AzureRmStorageAccountKey -ResourceGroupName $resourceGroupName -Name $storageAccountName $storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $accountKeys.Key1 $container = Get-AzureStorageContainer -Context $storageContext -Name $containerName $cbc = $container.CloudBlobContainer $permissions = $cbc.GetPermissions(); $policy = new-object 'Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy' $policy.SharedAccessStartTime = $(Get-Date).ToUniversalTime().AddMinutes(-5) $policy.SharedAccessExpiryTime = $(Get-Date).ToUniversalTime().AddYears(1) $policy.Permissions = "Read" $permissions.SharedAccessPolicies.Add($policyName, $policy) $cbc.SetPermissions($permissions); $policy = new-object 'Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy' $sas = $cbc.GetSharedAccessSignature($policy, $policyName) Write-Host $sas
-
Copy the ouput of the script (a Shared Access Signature) to the clipboard. It should look something like this:
?sv=2015-04-05&sr=c&si=BookNameTokens%20Policy%202&sig=hRQlxasvNZKX3voV%2FEsdf12sdf1MBmmDWRZsJ46bOYo%4X
-
Discussion points:
- Code walkthrough for PowerShell script
- Structure of a SAS
-
Try to open blob using a browser, but this time append the SAS. Your URL should look something like this:
https://bookrainerdev.blob.core.windows.net/booknametokens/BookNameTokens.txt?sv=2015-04-05&sr=c&si=BookNameTokens%20Policy%202&sig=hRQlxasvNZKX3voV%2FEsdf12sdf1MBmmDWRZsJ46bOYo%4X
. This time you should be able to download the blob.
-
Add the
BookNameTokenUrl
setting to yourweb.config
file. It contains the URL with the SAS. Note that you have to replace&
characters with&
asweb.config
is an XML file.<?xml version="1.0" encoding="utf-8"?> ... <configuration> <appSettings> <add key="MinimumNumberOfBooks" value="1"/> <add key="MaximumNumberOfBooks" value="5"/> <add key="BookNameTokenUrl" value="https://bookrainerdev.blob.core.windows.net/booknametokens/BookNameTokens.txt?sv=2015-04-05&sr=c&si=BookNameTokens%20Policy%202&sig=hRQlxasvNZKX3voV%2FEsdf12sdf1MBmmDWRZsJ46bOYo%4X"/> </appSettings> ... </configuration>
-
Search for the following line in
Services/NameGenerator.cs
:var bookNameTokens = await Task.FromResult(bookNameTokensDummy);
. Describe that we have to replace the static book name tokens with a call to Blob Storage. -
Replace
Services/NameGenerator.cs
with the implementation from Exercise-2-Service-Implementation. -
Discussion points:
- Demonstrate downloading of book name tokens from Blob Storage in the debugger
- Point out that it is inefficient to download the tokens whenever a book title is generated. However, this "bug" is in the sample by design as we can later "find" this potential for optimization using telementry data.
-
Run your Web Api
http://localhost:2690/api/books
using a browser or Postman and note how the book names are now generated based on data from Azure Storage.
If you have time left, you could additionally cover topics like:
- Show demo for creating artifacts in Azure using Azure CLI
- Show blob storage client tools you use in practise
- Speak about how Azure Search can be used on top of different storage offerings to add full-text search