定期删除Azure存储账号下N天之前的数据文件-ARM
######RemoveStorageBlob*DaysOld-ARM#####
<#
.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-arm-new
{
param(
#设置Org ID
[parameter(Mandatory=$true)]
[String]$AzureOrgId="***", #设置Org ID的密码
[Parameter(Mandatory = $true)]
[String]$Password="***", #设置订阅名称
[Parameter(Mandatory = $true)]
[String]$AzureSubscriptionName="***", #设置存储账号所在的资源组
[Parameter(Mandatory = $true)]
[String]$ResourceGroupName="***", #设置存储账号
[Parameter(Mandatory = $true)]
[String]$StorageAccountName="***", #设置Container Name
[Parameter(Mandatory = $true)]
[String]$ContainerName="***", #设置过期时间
[Parameter(Mandatory = $true)]
[Int32]$DaysOld=
) $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-AzureRmAccount -Credential $AzureOrgIdCredential -environmentname "AzureChinaCloud" | Write-Verbose # Set-AzureSubscription -SubscriptionName $AzureSubscriptionName -CurrentStorageAccountName $StorageAccountName Select-AzureRmSubscription -SubscriptionName $AzureSubscriptionName
Set-AzureRmCurrentStorageAccount -ResourceGroupName $ResourceGroupName -StorageAccountName $StorageAccountName # loop through each container and get list of blobs for each container and delete
$blobsremoved =
$containers = Get-AzureStorageContainer -Name $ContainerName -ErrorAction SilentlyContinue #$storage = Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName
#write-output $storage
#$context = [Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext]$storage.Context;
#Write-Output($storage.Context.gettype());
#$containers = Get-AzureStorageContainer -Name $ContainerName -Context $context -ErrorAction SilentlyContinue
#$containers = $storage | Get-AzureStorageContainer -Name $ContainerName foreach($container in $containers)
{
$blobsremovedincontainer =
Write-Output ("Searching Container: {0}" -f $container.Name)
#$blobs = Get-AzureStorageBlob -Container $ContainerName -Context $context
#$blobs = $storage | Get-AzureStorageBlob -Container $ContainerName
$blobs = Get-AzureStorageBlob -Container $ContainerName 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 +=
$blobsremovedincontainer +=
}
}
}
} 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天之前的数据文件-ARM的更多相关文章
- 定期删除Azure存储账号下N天之前的数据文件-ASM
######RemoveStorageBlob*DaysOld##### <# .SYNOPSIS Remove all blob contents from one storage accou ...
- 通过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)门户页面时,从 "访问控制(标识和访问管理)" 页面中发现有"拒绝分配"的功能,所以就思考, ...
随机推荐
- [Selenium]刷新页面 Refresh page
5 different ways to refresh a webpage using Selenium Webdriver Here are the 5 different ways, usin ...
- 2016-2017-20155329 《Java程序设计》第6周学习总结
学号 2016-2017-20155329 <Java程序设计>第6周学习总结 教材学习内容总结 数据从来源取出:输入串流 java.io.InputStream 写入目的的:输出串流 j ...
- Linux服务器上日志报com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1783 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
在做查询数据库操作时,报了以上错误,还有out of memery heap hacp ,原因是MySQL的max_allowed_packet设置过小引起的,我一开始设置的是1M,后来改为了20M ...
- CentOS7通过 yum安装路径查询方法
CentOS7通过 yum安装路径查询方法 rpm -qa 然后执行 rpm -ql 软件名称 就可以显示软件的安装路径. 原文博客的链接地址:https://cnblogs.com/qzf/
- HTML5 桌面消息提醒
Notification HTML5新属性,复制代码创建HTML文件,浏览器查看效果 <!DOCTYPE html> <html lang="en"> &l ...
- 网络排错与网络命令的理解ping-traceroute-host(nslookup)-tcpdump获取对方的mac
1. 虚拟机中NAT架构的网络结构中, 虚拟网卡VMnet8(192.168.134.1)是连接宿主主机. 用虚拟网段中主机(192.168.134.133),ping VMnet8 为什么没有响 ...
- 四则运算生成器(java) 蔡苑菲,陆海燕
github地址:https://github.com/Nancy0611/Myapp.git 一.项目相关要求 使用 -n 参数控制生成题目的个数,例如 Myapp.exe -n 10 将生成10个 ...
- 注解Annotation补充介绍
摘抄http://www.cnblogs.com/peida/archive/2013/04/23/3036035.html 什么是注解(Annotation): Annotation(注解)就是Ja ...
- test4 结对项目
[必做 1] 基于作业3的结果,读取一个较小的文本文件A_Tale_of_Two_Cities.txt,统计该文件中的单词的频率,并将统计结果输出到当前目录下的 Result1.txt 文件. 结对对 ...
- 开通博客暨注册github事件
(1) 姓 名:丁新宇 学 号:1413042054 班 级:网工142 兴趣爱好:听歌.看书.编代码. (2) GitHub注册流程: 1,百度搜索GitHub,进入官 ...