-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathUploadResources.ps1
54 lines (40 loc) · 1.56 KB
/
UploadResources.ps1
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
Param([string]$storageKey)
function Add-Entity() {
[CmdletBinding()]
param(
$table,
[String]$partitionKey,
[String]$rowKey,
[String]$text,
[String]$status
)
$entity = New-Object -TypeName Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity -ArgumentList $partitionKey, $rowKey
$entity.Properties.Add("Text", $text)
$entity.Properties.Add("Status", $status)
$result = $table.CloudTable.Execute([Microsoft.WindowsAzure.Storage.Table.TableOperation]::InsertOrReplace($entity))
}
$StorageAccountName = "nuviotresources"
#$StorageAccountKey = Get-AzureStorageKey -StorageAccountName $StorageAccountName
$Ctx = New-AzureStorageContext $StorageAccountName -StorageAccountKey $storageKey
$TableName = "allresources"
Write-Output $ctx
$scriptPath = Split-Path $MyInvocation.MyCommand.Path
Set-Location $scriptPath
$SubscriptionName = "Primary"
# Give a name to your new storage account. It must be lowercase!
$StorageAccountName = "nuviotresources"
$table = Get-AzureStorageTable –Name $TableName -Context $Ctx -ErrorAction Ignore
#Create a new table if it does not exist.
if ($table -eq $null)
{
$table = New-AzureStorageTable –Name $TableName -Context $Ctx
}
$children = gci ./ -recurse *.resx
foreach( $child in $children){
$nuspecFile = gi $child.fullName
[xml] $content = Get-Content $nuspecFile
foreach($item in $content.root.data){
Add-Entity -Table $table -PartitionKey $child.name -RowKey $item.name -Text $item.value -Status new
# Write-Output $child.Name $item.name " " $item.value
}
}