Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
401 views
in Technique[技术] by (71.8m points)

powershell - How to send email with recent azure infrastructure deployment details

I have provisioned multiple resources in Azure by using ARM templates through the Azure DevOps CI & CD pipelines.

I have followed this documentation to get the recent deployment details based on the deployment name.

I am getting the recent deployment details by using this PowerShell command.

    $deployments = Get-AzResourceGroupDeployment -ResourceGroupName  $resourceGroupName | Sort-Object Timestamp -Descending

The above PS command is giving all the deployment details in the resource group. But I want to get the deployment details whatever I have deployed through the Azure DevOps CD pipeline.

For Example:

  1. In the release - 1, I have deployed below resources:

    AppService-Deployment
    Storage-Deployment
    Service Bus-Deployment
    

    I want to send the email with the above three deployment details

  2. In the release -2, I have deployed below resources:

    SQL-Deployment
    Cosmos-Deployment
    

    I want to send the email with the above two deployment details

So, can anyone suggest me how to do this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When you use ARM templates to deploy resources, you can set the deployment name in the ARM template deployment task.

enter image description here

Then, you can get the deployment by name when you get deployment details in the PowerShell task.

 $deployments = Get-AzResourceGroupDeployment -ResourceGroupName  $resourceGroupName -Name $deploymentName | Sort-Object Timestamp -Descending

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...