In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Today, let's discuss other applications of Azure automation. For cloud managers, they must want to have a comprehensive understanding of the assets in the cloud. Azure Portal is actually a good choice for this requirement. However, in many cases, the information that Portal knows is often not so comprehensive and very inefficient.
At this time, it is more efficient to use PowerShell for statistics of all kinds of information. You can use various scripts to calculate all kinds of information, including IaaS to PaaS services. If you want to collect this information on a regular basis, you can also combine Azure automation, define schedule, and then cooperate with the script to collect information.
Let's take a look at the specific implementation. First, create an automation account in Azure, and this will not be demonstrated. Then update our module and import the module we need, including azurerm.storage, azurerm.network, azurerm.profile and so on. You can take a look at the previous blog.
Https://blog.51cto.com/mxyit/2348123
With this content, the next step is to create a PowerShell runbook. There are many runbook for collecting information, including online and my own, which you can use according to your needs. In fact, I have introduced it many times before.
Use PowerShell to get the assignment of user rights in an Azure account
Https://blog.51cto.com/mxyit/2347819
Using PowerShell to quickly get SQL Server VM in Azure
Https://blog.51cto.com/mxyit/2347699
How to use PowerShell to collect Azure VM Image lists
Https://blog.51cto.com/mxyit/2070613
Here I use a script written by a foreign friend, because it covers more services.
Https://gallery.technet.microsoft.com/scriptcenter/Azure-Inventory-using-3db0f658?redir=0
The script itself stores the information on the hard disk, but since this information cannot be persisted in automation, we can modify it slightly and divide it into two levels.
1. Store the collected information as a csv file and save it in blob
two。 Send the csv file to the mailbox as an attachment
To do this, we need to make some changes based on the original script, add some content, take collecting virtual machine information as an example, and add the following after the virtual machine information collection script
# Define filename $filename= "Virtual_Machine_details_" + (Get-Date-UFormat'% Y% masked% d') + ".csv" $virtual_machine_object | Export-Csv-path $filename-NoTypeInformation-Force # Define blob info$StorageAccountName = "" $StorageAccountKey = "" $StorageAccountKey = "" $ctx = New-AzureStorageContext-StorageAccountName $StorageAccountName-StorageAccountKey$ StorageAccountKey$containername= "inventory" Set-AzureStorageBlobContent-Container $ContainerName-File $filename-Blob $filename-Context $ctx-Force # send email$uname = "your email account" $pwd = ConvertTo-SecureString-String "- AsPlainText-Force$cred = Force$cred ($Force$cred) $pwd) Send-MailMessage-from $uname-To'- Subject "Azure Environment daily check $(Get-Date-UFormat'% Y Get-Date% mAccord% d')"-Body $("Here's the Azure environment status today")
")-Attachments $filename-SmtpServer'- Credential $cred-UseSsl-BodyAsHtml
When you are finished, runbook link to schedule
Create a schedule
Then you can see it in schedule.
After running it, you can see an effect similar to the following. Of course, this is just a demonstration of getting VM information, and does not include anything else in the script.
Content stored in Blob
What is received in the email
In this way, you can see Azure's asset information when you come every morning!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.