简体   繁体   English

查找所有停止或没有部署的云服务(经典)

[英]Find all Cloud Services (Classic) which are stopped or have no deployments

I'm trying to write a script that will give me a list of unused Cloud Services in Azure.我正在尝试编写一个脚本,该脚本将为我提供 Azure 中未使用的云服务列表。 Unused, I mean which are stopped or have no deployments.未使用,我的意思是哪些已停止或没有部署。

I figure out how to do it with App Services, but stuck with Cloud Services, because of classic model.我想出了如何使用应用服务来做到这一点,但由于经典模型而坚持使用云服务。 I believe it requires different methods to call its properties, etc.我相信它需要不同的方法来调用它的属性等。

Could someone help me there to dig, or what methods, cmdlets to use to get these properties?有人可以帮我挖掘,或者使用什么方法,cmdlet 来获取这些属性?

Thanks in advance!提前致谢!

I thought it would have something similar:我认为它会有类似的东西:

    function check_site {
Write-Output "------------------------------------------"
Write-Output "Microsoft.Web/sites"
Write-Output "------------------------------------------"
$RT = "Microsoft.Web/sites"
$apps = Get-AzureRmResource -ODataQuery "`$filter=resourcetype eq 'Microsoft.Web/sites'"
foreach($app in $apps){
    $full_app = Get-AzureRmResource -ResourceGroupName $app.ResourceGroupName -ResourceType $RT -ResourceName $app.Name
    if("Running" -ne $full_app.Properties.state)
    {
        $1 = Get-AzureRmResource -ResourceGroupName $app.ResourceGroupName -ResourceType $RT -ResourceName $app.Name | Select-Object -ExpandProperty Name
        'App Service: ' + $1
    }
}}

For cloud services, you should use Get-AzureService to fetch the details.对于云服务,您应该使用Get-AzureService来获取详细信息。 Then you can use the related properties to determine if it's stopped or not.然后您可以使用相关属性来确定它是否已停止。

If you receive some errors when running this cmdlet, please use Add-AzureAccount cmdlet first.如果在运行此 cmdlet 时收到一些错误,请先使用Add-AzureAccount cmdlet。

The test result:测试结果:

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Velero 部署失败 - 找不到 Azure /credentials/cloud 文件 - Velero deployments failure - Unable to find Azure /credentials/cloud File 如何将存储在Azure存储中的cspkg部署到Azure云服务(经典)? - How to deploy an cspkg stored in Azure storage to Azure cloud services (classic)? 在Classic Cloud Services中可以使用ActiveDirectoryMembershipProvider,但不能在Azure Web App上使用 - Working ActiveDirectoryMembershipProvider in Classic Cloud Services but do not work on Azure Web App 将去往单个端点的流量重定向到Azure Cloud Services中的功能(经典) - Redirecting traffic going to a single endpoint to a function in Azure Cloud Services (classic) 使用某些命令自动缩放云服务 - Autoscaling of Cloud services which works with some commands 如何在远程桌面上编辑配置文件(Azure云服务(经典)文件的一部分)? - How to edit configuration files (part of Azure Cloud Services (Classic) files )on Remote Desktop? 如何获取资源组的所有部署列表(包括那些可能具有相同名称的部署)? - How do I get a list of all deployments for a resource group (including those that may have had the same name)? 为所有部署创建专用的内存缓存 - Create a dedicated memcache for all the deployments Azure:我的哪些云服务具有特定的IP地址? - Azure: which of my cloud services has a specific IP address? Azure云服务部署的错误日志 - Error log for Azure cloud service deployments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM