Credits To: Wriju Ghosh – For sharing the https://azure.microsoft.com/en-us/updates/ and RSS Feed URL https://azurecomcdn.azureedge.net/en-us/updates/feed/
It was a simple ask “How do we know Azure Service Updates?” The answer is to use the link (Azure Service Updates)! But, in this blog post I will show how to retrieve the feed information programmatically, store in Azure Table Storage and send weekly newsletter to business users. Yes, Azure Table Storage will be used to store the service update news once a day (preferably Seattle Local time)
Prerequisites
- PowerShell
- Office 365 (Exchange SMTP & Credentials)
- Azure DevOps (Pipelines)
Solution
Fetch Azure Service Updates
function Get-WeekNumber { param ( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] $DateTime ) process { $CurrentCulture = [cultureinfo]::CurrentCulture $CurrentCulture.Calendar.GetWeekOfYear([datetime]"$($DateTime)", [System.Globalization.CalendarWeekRule]::FirstDay, [System.DayOfWeek]::Monday) } } Install-Module -Name AzTable -Force -Verbose -Scope CurrentUser $Config = Get-Content .\config\config.json | ConvertFrom-Json Set-AzContext -SubscriptionId $($Config.Subscription) | Out-Null $StorageContext = New-AzStorageContext -StorageAccountName $($Config.StorageAccountName) -SasToken $($Config.StorageAccountKey) $CloudTable = (Get-AzStorageTable -Name $($Config.TableName) -Context $($StorageContext)).CloudTable $AzureUpdates = Invoke-RestMethod -Uri "https://azurecomcdn.azureedge.net/en-us/updates/feed/" $AzureUpdates | . { process { Add-AzTableRow -Table $CloudTable -PartitionKey "Microsoft.Azure.Updates.Feed" -RowKey $($_.guid.'#text') -property @{ WeekNumber = (Get-WeekNumber -DateTime $_.pubDate) Title = $_.Title Category = $_.Category -split "," -Join "," PublishedDate = ([datetime]($_.pubDate)).ToShortDateString() ReferenceLink = $_.link } -UpdateExisting } }
{ "Subscription": "SUBCRIPTION ID", "StorageAccountName": "STG ACC NAME", "TableName": "TABLE NAME", "StorageAccountKey": "SECRET KEY", "TenantID": "TENANT ID", "ClientID": "CLIENT ID", "ClientSecret": "CLIENT SECRET", "O365Admin": "ADMIN", "O365Password": "Password" }
With no doubt you have to replace the parameter values in config.json. For a demo purpose I used secrets in config file, please plan as per the security standards at your work place.
Now, we need to send consolidated weekly report. The below snippet will help us – Replace the user name and password for O365.
Install-Module -Name AzTable -Force -Verbose -Scope CurrentUser $Config = Get-Content .\config\config.json | ConvertFrom-Json Set-AzContext -SubscriptionId $($Config.Subscription) | Out-Null $StorageContext = New-AzStorageContext -StorageAccountName $($Config.StorageAccountName) -SasToken $($Config.StorageAccountKey) $CloudTable = (Get-AzStorageTable -Name $($Config.TableName) -Context $($StorageContext)).CloudTable $WeekNumber = Get-Date -UFormat %V $AzureUpdates = Get-AzTableRow -Table $CloudTable -CustomFilter "(WeekNumber eq $WeekNumber)" Install-Module PSHTML -Scope CurrentUser -Verbose -Force $EmailBody = html -Content { head -Content { } body -Content { table -Content { table -Content { tr -Content { th -Content "Week Number" th -Content "Published Date" th -Content "Title" th -Content "ReferenceLink" } tr -Content { $AzureUpdates | . { process { tr -Content { td -Content $_.WeekNumber td -Content $_.PublishedDate td -Content $_.Title td -Content { a -href $($_.ReferenceLink) -Content "Reference Link" } } } } } } } } } $UserName = $($Config.O365Admin) $Password = $($Config.O365Password) | ConvertTo-SecureString -AsPlainText -Force $Credential = [pscredential]::new($UserName , $Password) $MailParams = @{ From = "AzureServiceUpdate@Microsoft.com" To = "Chendrayan.Exchange@hotmail.com" Subject = "Azure Service Updates - Weekly | Week ($(Get-Date -UFormat %V)) | Year $((Get-Date).Year)" SmtpServer = "smtp.office365.com" Body = $EmailBody BodyAsHtml = $true Port = 587 UseSSL = $true } Send-MailMessage @MailParams -Credential $Credential
In my next blog post I will share the Az Pipeline information and other interesting requirements.