How to send Azure Runbook Output in an excel and attach it to an email

Sahil Wadehra 1 Reputation point
2022-09-09T04:40:39.123+00:00

Is there any way we can Write the Output of an Azure PS Runbook into an csv and attach it on the email and send to recipients. I was able to send the output as csv to Blob and also send output to email with Logic App but unable to do above. Please guide and thank you in advance !! Below is a small sample PS Query I am running via my Azure Runbook -

Login-AzAccount -Identity

Get-AzConsumptionUsageDetail -StartDate 2022-06-27 -EndDate 2022-07-29 -Top 10 | sort -Descending PretaxCost, UsageQuantity | Select InstanceName, ConsumedService, PretaxCost, UsageQuantity, InstanceId, InstanceLocation, SubscriptionName, CostCenter, MeterId, Product, Tags

Write-Output "Current Cost of Subscription : " $currentCost.Sum

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,366 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. David Broggy 6,291 Reputation points MVP Volunteer Moderator
    2022-09-09T18:47:59.36+00:00

    Hi SahilWadehra,
    I asked a similar question recently and the consensus was that I'd need my own smtp server in order to forward the output to email.
    However if you use the Logic Apps web UI to export your data you'll have the ability to email from your Outlook account.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.