Category Archives: Azure

Azure: Email a Backup Report with PowerShell and Office365

Azure PortalThis PowerShell snippet compiles a daily report of backup jobs on all the Recovery Service Vaults within the current subscription. It then uses the Office 365 SMTP server to mail this report out to chosen recipients – if you’re not using O365 then just change the SMTPServer, Port, and UseSSL arguments as appropriate in the Send-MailMessage cmdlet.

$Body=foreach ($RSV in Get-AzRecoveryServicesvault) {
Get-AzRecoveryServicesBackupJob -VaultID $RSV.ID -Operation "Backup" -From ((Get-Date).AddDays(-1).ToUniversalTime()) |
Select-Object WorkloadName,Operation,Status,StartTime,EndTime,Duration
}
$Body= "
<h1>Daily Azure Backup Report: "
+ (Get-AzSubscription).Name +"</h1>
<code>"
+ ($Body | ConvertTo-HTML)+"</code>"
Send-MailMessage -BodyAsHTML $Body -From "[email protected]" `
-To "[email protected]" -SmtpServer smtp.office365.com -Port 587 `
-Subject "Azure Backup Report" -UseSsl `
-Credential (Get-Credential -Message "Office 365 credentials")

If the email should go to multiple recipients then comma separate the list as follows:

Send-MailMessage -To @("[email protected]","[email protected]")

Obviously to automate this you’ll need to feed the credentials in, using whatever secure platform you have available, rather than prompting for them in the script. The resulting email looks something like this:
Email
There’s plenty of scope for customisation of the email – the style and look of it can be changed by manipulating the HTML that’s generated in the snippet and the information included can be changed by modifying the Select-Object parameters.

Azure Arc Announcement

Microsoft released an 87 page “Book of New” listing the announcements  from this weeks Ignite Conference and right at the top is Azure Arc. It’s not just alphabetical order that put’s this new product here, in my opinion this is a real step forward by Microsoft towards fulfilling the early promise of their Azure Hybrid Cloud model.

Arc’s first feature provides the ability to run Azure data services – Azure SQL Server and friends- on any platform, be it on-premises, on an edge device, or in the public cloud. We saw VMware advertising this from their point of view in the VMworld Europe keynote this week. Bringing Platform-As-A-Service to your own platform, or those at another cloud provider, is an interesting concept and vital to the idea of a true hybrid environment where you can run any app on any cloud.

Whilst Azure stack provided “Azure consistent hardware” in your datacentre, Azure Arc continues this journey – in essence expanding what “Azure consistent” means to the customer in terms of data services.

Azure Arc also extends the security, governance and management from Azure into other environments – coming back to a single architecture.

Azure hybrid innovation anywhere infographic

For me this is the key feature of this technology. With Azure Arc sitting at the heart of the Azure Hybrid model we’re one step closer to that utopia where the datacentre is abstracted away in the same way that virtualisation abstracted away the server hardware. You can do this abstraction in the public clouds, but there are still workloads that have regulatory, financial, or technical reasons for staying on-premises (or even a different public cloud) and until now managing these alongside Azure has meant two different platforms.

 image

Previously Azure Stack (and to a certain extent Azure Stack HCI) came close to providing this true hybrid functionality for Microsoft but there was still a disconnect- you have to visit a separate Azure portal to manage your on-premises Azure Stack “Region” for example.

In the Arc environment, an Azure agent is deployed to non-Azure VMs (or physical servers) and then they appear on the Azure Portal as a regular resource. Policies can be applied and compliance audited (remediation is expected in the “next few months”). The people in your Security Team who got excited about what was possible with Policies in Azure can now apply the same policy features to VMs in your datacentre and from the same interface.

image

As I implied above, this is still a journey in progress and I believe Microsoft have further to travel down this roadmap, but this is definitely a big step along their way and provides very useful features now and promise of an even brighter future.

As you would expect, there’s a number of recorded sessions at Microsoft Ignite 2019 covering this new product following it’s announcement in the keynotes. If you’re interested in finding out more I would suggest starting with BRK2208 : Introducing Azure Arc. Azure Arc is currently available in Preview and usable from the portal today.

image

Improving Documentation via the Community.

Have you ever had to deal with incorrect documentation? Or been frustrated by a typo? Or been annoyed that a how-to guide uses an old version of an interface?

Now you can fix it!

Many software providers are now using community-editable documentation online. This isn’t a Wikipedia style free-for-all, but a carefully moderated process ensuring that the resulting document is accurate.  If you come across an error in an online doc, or even a PowerShell help page, check and see if you can submit edits.

Continuous deployment pipelines mean that these edits can make it into live documentation in a matter of hours or days- impressive times if you’ve ever submitted an errata to a printed book, or submitted a bug request to get online documentation fixed.

docs.Microsoft.com

If you visit a Microsoft docs page, you’ll see an Edit link at the top of the screen (see (1) in the screenshot below). Clicking on this takes you to a page on Github with the source of the document. Click there to edit the file and a git fork will be made under your own profile- make your edits and submit a merge request and, once approved, your updates will appear in the original website. You’ll even get a little credit (see (2) in the screenshot below) for your contribution.

image

In this particular example I was following the step-by-step guide and noticed that the wording in the document no longer matched the Azure Portal. I was quickly able to suggest a fix and later that day the page was updated and anyone else following the instructions wouldn’t be misled. Two minutes of my time hopefully saved ten minutes of head-scratching by someone else.

VMware PowerCLI Example Scripts

As the name suggests, the source code for some example PowerCLI scripts has been published by VMware supported by members of the #vCommunity. If you find an error in the scripts you can pop over to Github and correct them- and remember this isn’t just the code of the script, but also it’s accompanying documentation.

image

In this example a typo in the get-help file was spotted and quickly corrected. Whilst the spelling mistake wasn’t a show-stopper this shows how quick and easy it is to contribute to these projects without being a coding guru.

Summary

Many of these projects use Github and learning how to use that version control platform isn’t arduous- especially for small changes like these- and is a useful skill to pickup if you don’t already have it. The important message here is you don’t need to be a developer to contribute to the code.

So, next time you spot a mistake in documentation, see if you can fix it yourself and help the next person who comes along.

Azure: Deploy a WebApp with PowerShell

A quick runthrough on using PowerShell to deploy a new WebApp. ASP.NET code for the website has been zipped up (into myapp.zip) and this code snippet will upload it to a new WebApp, hosted in a new App Service Plan and a new Resource Group.

From a local PowerShell session use Connect-AZAccount before running this code to sign-in to Azure. Alternatively this code can be run (with the exception of the upload itself) from the Cloud Shell directly in the Azure Portal.

The code also writes out the URL of the resulting WebApp and the PowerShell necessary to tear down the resources when they are no longer required.

#Set some parameters
$location="UK South"
$resourceGroupName= “rsg-myapp”
$webAppName=”web-myapp”
$appServicePlanName=”asp-myapp”
$codeZIPPath=”C:\myapp.zip”

#Create Resource Group
"-- Creating Resource Group"
New-AzResourceGroup -Location $location -Name $resourceGroupName -tag $Tags

#Create ServicePlan
"-- Creating Service Plan"
New-AzAppServicePlan -ResourceGroupName $resourceGroupName -Name $appServicePlanName -Location $location -Tier Free

#Create Web App
"-- Creating Web App"
New-AzWebApp -ResourceGroupName $resourceGroupName -Name $webAppName -Location $location -AppServicePlan $appServicePlanName

#Upload the web code
"-- Uploading Web App Code"
Publish-AzWebApp -ResourceGroupName $resourceGroupName -Name $webAppName -ArchivePath $codeZIPPath –Force

#Show user code to destroy this (useful for testing)
#  and the website that has been created.
"-- Tidy Up Code: "
" Remove-AzResourceGroup -Name $resourceGroupName"
"-- Website: "
"-- https://$WebAppName.azurewebsites.net"

"-- Done"

The resulting website can be viewed just by pointing a browser at the given URL. The created resources can be checked in the Azure portal:

image

Microsoft Azure Fundamentals

Earlier this week I took and passed the Microsoft AZ-900 exam- the requirement for the Microsoft Azure Fundamentals badge. Whilst this is the entry-level cert and not a requirement for the more advanced ones in the pathways, it is still useful for experienced techies moving into the Azure space, perhaps from other cloud platforms or on-premises architectures.

I had some prior experience dabbling in Azure, so wasn’t coming into this green. This was coupled with my general experience in server and cloud technologies so the generic concepts weren’t new to me. But I personally found working to the certification a useful way of ensuring I have a good grounding in the platform and specific terminologies before moving onto other things.

azure-fundamentals-600x600

Learning Materials

There’s plenty of material out there, including a new book, but I studied by going through the free online “Azure fundamentals” learning path from Microsoft: https://docs.microsoft.com/en-us/learn/paths/azure-fundamentals/

This is a series of articles, short videos, and mini-tests with a couple of practical exercises in the Azure Portal thrown in. It covers everything from the basics (what is cloud computing etc.) through to some of the specific Azure products which are in the exam syllabus.

I coupled this learning pathway with some further exploration and experimentation in the Azure Portal and associated documentation.

The Exam

The exam itself- once all the pre-ramble, surveys, and commenting sections are removed – is 60 minutes and my test had (IIRC) 44 questions. The first 5/6 questions were in a separate section where I couldn’t revisit them once I’d answered and moved on, but for the remainder I was able to go back and forth and review as necessary.

Question Styles

No, I’m not going to reveal what questions I was asked, but knowing the way the questions can be asked in advance is helpful. It’s been some years since I took a Microsoft exam and question styles change.

My particular test (and remember, they’re all different) had a mixture of multiple choice (sometimes just one of four answers, sometimes more than one may have been required) and drag-and-drop answers. Within the multiple choice there were also a number of questions where I was given a statement and had to replace (if necessary) the words given in bold. For example (and this is obviously not a real AZ-900 question!)

The Microsoft Solitaire game was first released with Windows 95 to help introduce the graphical user interface.

Review the text in bold. If it makes the statement correct select “No change needed”, otherwise select the answer which makes the statement correct.

  • A-No change needed
  • B-Windows 3.0
  • C-Windows Bob
  • D-OS X

Correct Answer- B

Check out the “Exam formats and question types” videos from Microsoft for more detail.

Subjects Covered

The subjects are fully covered in the “Skills Measured” section of the exam webpage and I felt there was a good match between these lists and the questions I was posed on the day.

Going into this with a firm background in the generic cloud concepts the trickiest part for me was matching up which Azure product does what and remembering the names. I’d recommend making sure you’ve remembered as many as possible of these from the core offerings- and also be prepared to spot fake product names in the multiple choice (I’m pretty sure I saw a few of these). For example (and again, not a real AZ-900 question!)

In Microsoft Windows 10, which application could you use to assign local administrator rights to an Active Directory user.

  • A-Active Directory Users and Computers
  • B-Local Users and Groups
  • C-Windows Administrator Control
  • D-Microsoft Rights Manager

Correct Answer- B. As far as I know C and D don’t exist.

Conclusion

I’m obviously happy with my pass, and I’d recommend looking at this to anyone starting out on an Azure journey, possibly from scratch or by transitioning from other technologies. The exam isn’t compulsory, but it does validate your learning- either to yourself or your employer.