Reputation: 144
The json file may have one or more blocks of data as shown below.
[
{
"ApplicationName": "123456.Abcv.WFcvsdfa",
"SecretKey": "NDRkNDJjOTAtZjBhYi00NctYjkwYTNlMjNmZTQy"
}
]
OR
[
{
"ApplicationName": "753456.Abcv.WFcvsdfa",
"SecretKey": "NDRkNDJjOTAtZjBhYi00NctYjkwYTNlMjNmZTQy"
},
{
"ApplicationName": "9045647.GQERDF.GDEAGJWSasdf",
"SecretKey": "OTlmMmMxYjgtZjEzMS00MTkwLWI1NDQtYjI2MT"
}
{
"ApplicationName": "1523456.Abcv.WFcvsdfa",
"SecretKey": "NDRkNDJjOTAtZjBhYi00NctYjkwYTNlMjNmZTQy"
},
{
"ApplicationName": "3645647.GQERDF.GDEAGJWSasdf",
"SecretKey": "OTlmMmMxYjgtZjEzMS00MTkwLWI1NDQtYjI2MT"
}
{
"ApplicationName": "5423456.Abcv.WFcvsdfa",
"SecretKey": "NDRkNDJjOTAtZjBhYi00NctYjkwYTNlMjNmZTQy"
},
{
"ApplicationName": "6445647.GQERDF.GDEAGJWSasdf",
"SecretKey": "OTlmMmMxYjgtZjEzMS00MTkwLWI1NDQtYjI2MT"
}
]
The secrets name should be ApplicationName. Dots must be removed from the application name.
Thanks, appreciate a lots your help
Upvotes: 0
Views: 1818
Reputation: 144
Here I got the solution for this post, may it will be helpful for others in future.
$VaultName = "test900066"
$hashtable = Get-Content 'out.json' | ConvertFrom-Json
foreach ($h in $hashtable.GetEnumerator()) {
$SecureString = ConvertTo-SecureString $h.SecretKey -AsPlainText -Force
$ApplicationName = $h.ApplicationName -Replace '\.',''
# Write-Host "$($ApplicationName) : $SecureString"
Set-AzKeyVaultSecret -VaultName $VaultName -Name $ApplicationName -SecretValue $SecureString
}
Upvotes: 1