定期删除Azure存储账号下N天之前的数据文件-ASM
######RemoveStorageBlob*DaysOld#####
<#
.SYNOPSIS
Remove all blob contents from one storage account that are * days old.
.DESCRIPTION
This script will run through a single Azure storage account and delete all blob contents in
all containers, which are * days old. #> workflow delblob-asm
{
param(
#设置Org ID
[parameter(Mandatory=$true)]
[String]$AzureOrgId="***", #设置Org ID的密码
[Parameter(Mandatory = $true)]
[String]$Password="***", #设置订阅名称
[Parameter(Mandatory = $true)]
[String]$AzureSubscriptionName="***", #设置存储账号
[Parameter(Mandatory = $true)]
[String]$StorageAccountName="***", #设置Container Name
[Parameter(Mandatory = $true)]
[String]$ContainerName="***", #设置过期时间
[Parameter(Mandatory = $true)]
[Int32]$DaysOld=10
) $ChinaTimeZone = [System.TimeZoneInfo]::FindSystemTimeZoneByID("China Standard Time")
$Start = [System.TimeZoneInfo]::ConvertTimefromUTC((get-date).ToUniversalTime(),$ChinaTimeZone)
"Starting: " + $Start.ToString("HH:mm:ss.ffffzzz") $AzurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
$AzureOrgIdCredential = New-Object System.Management.Automation.PSCredential($AzureOrgId,$AzurePassword) Add-AzureAccount -Credential $AzureOrgIdCredential -environment "AzureChinaCloud" | Write-Verbose Set-AzureSubscription -SubscriptionName $AzureSubscriptionName -CurrentStorageAccountName $StorageAccountName
Select-AzureSubscription -SubscriptionName $AzureSubscriptionName # loop through each container and get list of blobs for each container and delete
$blobsremoved = 0
$containers = Get-AzureStorageContainer -Name $ContainerName -ErrorAction SilentlyContinue foreach($container in $containers)
{
$blobsremovedincontainer = 0
Write-Output ("Searching Container: {0}" -f $container.Name)
$blobs = Get-AzureStorageBlob -Container $container.Name if ($blobs -ne $null)
{
foreach ($blob in $blobs)
{
$lastModified = $blob.LastModified
if ($lastModified -ne $null)
{
$blobDays = ([DateTime]::Now - [DateTime]$lastModified)
Write-Output ("Blob {0} in storage for {1} days" -f $blob.Name, $blobDays) if ($blobDays.Days -ge $DaysOld)
{
Write-Output ("Removing Blob: {0}" -f $blob.Name)
Remove-AzureStorageBlob -Blob $blob.Name -Container $container.Name
$blobsremoved += 1
$blobsremovedincontainer += 1
}
}
}
} Write-Output ("{0} blobs removed from container {1}." -f $blobsremovedincontainer, $container.Name)
} $ChinaTimeZone = [System.TimeZoneInfo]::FindSystemTimeZoneByID("China Standard Time")
$Finish = [System.TimeZoneInfo]::ConvertTimefromUTC((get-date).ToUniversalTime(),$ChinaTimeZone) $TotalUsed = $Finish.Subtract($Start).TotalSeconds Write-Output ("Removed {0} blobs in {1} containers in storage account {2} of subscription {3} in {4} seconds." -f $blobsRemoved, $containersremoved, $StorageAccountName, $AzureConnectionName, $TotalUsed)
"Finished " + $Finish.ToString("HH:mm:ss.ffffzzz")
}
定期删除Azure存储账号下N天之前的数据文件-ASM的更多相关文章
- 定期删除Azure存储账号下N天之前的数据文件-ARM
######RemoveStorageBlob*DaysOld-ARM##### <# .SYNOPSIS Remove all blob contents from one storage a ...
- 通过Azure 存储账号URL鉴别是标准磁盘还是高性能磁盘
对于不知道虚拟机磁盘是标准磁盘还是高性能磁盘时,我们可以通过nslookup解析存储账号的URL,来判断存储账号的类型,从而得知虚拟磁盘的类型 1.标准存储账号的解析结果,字母"st&quo ...
- SQL SERVER大话存储结构(6)_数据库数据文件
数据库文件有两大类:数据文件跟日志文件,每一个数据库至少各有一个数据文件或者日志文件,数据文件用来存储数据,日志文件用来存储数据库的事务修改情况,可用于恢复数据库使用. 这里分 ...
- 在windows下,将mysql离线数据文件导入本地mysql数据库
1. 查看mysql路径 SELECT @@basedir AS basePath FROM DUAL 其实mysql5.6 的数据文件在 C:\ProgramData\MySQL\MySQL Ser ...
- 在没有备份的情况下重新创建丢失的数据文件 (Doc ID 1149946.1)
Recreating a missing datafile with no backups (Doc ID 1149946.1) APPLIES TO: Oracle Database - Enter ...
- 如何Windows下配置Prometheus的监控数据文件为3天
如上图,prometheus的data文件夹时间久了会变得很大,听说是保留15天的数据.但是实际上,我只需要保留3天的数据就够了,之前试过用批处理文件清理,但是强行删除会导致peometheus崩溃, ...
- Linux下Mysql 不能访问新数据文件夹问题
新挂载的盘,打算将数据文件夹配置到 /data/mysql,却无法启动mysqld. 除了将目录授权给mysql用户和组以外 chown -R mysql:mysql /data/mysql 太需要将 ...
- Azure Automation (2) 定期删除存储账号中的文件
<Windows Azure Platform 系列文章目录> 本文介绍的是国内由世纪互联运维的Azure China. 本文是对笔者之前的文档Azure Backup (1) 将SQL ...
- 【Azure 环境】由为存储账号(Storage Account)拒绝分配权限而引出的Azure 蓝图(Blueprint)使用问题
问题描述 当打开Azure存储账号(Storage Account)门户页面时,从 "访问控制(标识和访问管理)" 页面中发现有"拒绝分配"的功能,所以就思考, ...
随机推荐
- ubuntu17.10 安装CUDA
1. 更新apt-get源列表 sudo apt-get update sudo apt-get upgrade 2. 添加驱动源 sudo add-apt-repository ppa:graphi ...
- 127. Word Ladder (Tree, Queue; WFS)
Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest t ...
- Python打包工具
打包Python应用,使用工具: 1.Linux和Windows下,使用pyinstaller pyinstaller -F -w XXX.py 在当前文件夹下生成两个文件夹:build .dist ...
- Eigen库和STL容器冲突问题
博客参考:https://blog.csdn.net/huajun998/article/details/54311561 在程序中想使用类似于如下的容器 std::vector<Eigne:: ...
- Vue 路由缓存
问题 在路由切换时不需要每次 点击都刷新子路由 尤其是在form表单的情况下 不能让用户 输入一半之后点击其他页面 再点回来 表单数据不见了 解决方案 vue 2.0 之中 有k ...
- HBase 系列(三)HBase Shell
HBase 系列(三)HBase Shell ./hbase shell # 进入 hbase 命令行 (1) HBase 命令帮助 help # 查看 HBase 所有的命令 create # 或 ...
- ACTIVIT 5.15.1修改记录
1.ProcessDefinitionEntity 将 protected transient ActivitiEventSupport eventSupport; 修改成: protected A ...
- BurpSuite安装和配置
Burp Suite是什么 Burp Suite 是用于攻击web 应用程序的集成平台.它包含了许多Burp工具,这些不同的burp工具通过协同工作,有效的分享信息,支持以某种工具中的信息为基础供另一 ...
- 洛谷P4312 [COCI 2009] OTOCI / 极地旅行社(link-cut-tree)
题目描述 不久之前,Mirko建立了一个旅行社,名叫“极地之梦”.这家旅行社在北极附近购买了N座冰岛,并且提供观光服务. 当地最受欢迎的当然是帝企鹅了,这些小家伙经常成群结队的游走在各个冰岛之间.Mi ...
- bootstrap-treeview中文API 以及后台JSON数据处理
bootstrap-treeview 简要教程 bootstrap-treeview是一款效果非常酷的基于bootstrap的jQuery多级列表树插件.该jQuery插件基于Twitter Bo ...