forked from Azure/azure-storage-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean_up.php
88 lines (70 loc) · 2.79 KB
/
clean_up.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* LICENSE: The MIT License (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://github.com/azure/azure-storage-php/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @category Microsoft
* @package MicrosoftAzure\Storage\Samples
* @author Azure Storage PHP SDK <[email protected]>
* @copyright 2019 Microsoft Corporation
* @license https://github.com/azure/azure-storage-php/LICENSE
* @link https://github.com/azure/azure-storage-php
*/
require_once "./vendor/autoload.php";
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
use MicrosoftAzure\Storage\File\FileRestProxy;
use MicrosoftAzure\Storage\Table\TableRestProxy;
use MicrosoftAzure\Storage\Queue\QueueRestProxy;
$connectionString = \getenv("AZURE_STORAGE_CONNECTION_STRING");
$blobClient = BlobRestProxy::createBlobService($connectionString);
$queueClient = QueueRestProxy::createQueueService($connectionString);
$fileClient = FileRestProxy::createFileService($connectionString);
$tableClient = TableRestProxy::createTableService($connectionString);
//clean up containers
$result = $blobClient->listContainers();
foreach ($result->getContainers() as $container) {
$blobClient->deleteContainer($container->getName());
}
//clean up queues
$result = $queueClient->listQueues();
foreach ($result->getQueues() as $queue) {
$queueClient->deleteQueue($queue->getName());
}
//clean up fileshares
$result = $fileClient->listShares();
foreach ($result->getShares() as $share) {
$fileClient->deleteShare($share->getName());
}
//clean up tables
$result = $tableClient->queryTables();
foreach ($result->getTables() as $table) {
$tableClient->deleteTable($table);
}
//clean up premium blobs
$connectionString = \getenv("AZURE_STORAGE_CONNECTION_STRING_PREMIUM_ACCOUNT");
if (!empty($connectionString)) {
$blobClient = BlobRestProxy::createBlobService($connectionString);
//clean up containers
$result = $blobClient->listContainers();
foreach ($result->getContainers() as $container) {
$blobClient->deleteContainer($container->getName());
}
}
//clean up blob storage blobs
$connectionString = \getenv("AZURE_STORAGE_CONNECTION_STRING_BLOB_ACCOUNT");
if (!empty($connectionString)) {
$blobClient = BlobRestProxy::createBlobService($connectionString);
//clean up containers
$result = $blobClient->listContainers();
foreach ($result->getContainers() as $container) {
$blobClient->deleteContainer($container->getName());
}
}