아래 PowerShell 스크립트를 실행하여 Azure 테이블 저장소에 CSV 파일 데이터를 배포합니다. 하지만 아래의 매개 변수는 하늘빛의 환경에 따라 다릅니다. 아래의 스크립트는 모든 환경에 배포 할 수 있지만 환경에 따라 아래 매개 변수가 달라질 수 있습니다. 스크립트에서 실행하는 동안 아래 매개 변수를 전달하고 싶습니다. VSTS.How에서 PowerShell을 작업은 this.SoVSTS에서 빌드하는 동안 PowerShell 스크립트에 매개 변수를 전달하는 방법
**$subscriptionName = "Tech Enabled Solutions"
$resourceGroupName = "abc"
$storageAccountName = "defghi"
$location = "North Central US, South Central US"
$StorageAccountKey = "12345678"**
PowerShell을 스크립트에 나를 도와 task.Please 달성하기 :
function Add-Entity()
{
[CmdletBinding()]
param
(
$table,
[string] $partitionKey,
[string] $RowKey,
[string] $Label_Usage,
[string] $Label_Value,
[string] $Usage_Location,
[string] $subscriptionName,
[string] $resourceGroupName,
[string] $storageAccountName,
[string] $location,
[string] $StorageAccountKey
)
$entity = New-Object -TypeName Microsoft.WindowsAzure.Storage.Table.DynamicTableEntity -ArgumentList $partitionKey, $rowKey
$entity.Properties.Add("Label_Value",$Label_Value)
$entity.Properties.Add("Label_Usage",$Label_Usage)
$entity.Properties.Add("Usage_Location",$Usage_Location)
$result = $table.CloudTable.Execute([Microsoft.WindowsAzure.Storage.Table.TableOperation]::InsertOrReplace($entity))
}
$tableName = "sampletable"
# Get a storage context
$ctx = New-AzureStorageContext $StorageAccountName $StorageAccountKey
# Get a reference to the table
$table = Get-AzureStorageTable -Name $tableName -Context $ctx -ErrorAction Ignore
$csv = Import-CSV "d:\a\1\s\DeploymentScripts\sampletable.csv"
ForEach ($line in $csv)
{
Add-Entity -Table $table -partitionKey $line.partitionkey -rowKey $line.RowKey -Label_Usage $line.Label_Usage -Label_Value $line.Label_Value -Usage_Location $line.Usage_Location
}
지정 여기서 매개 변수를 추가 할 수 있습니다. 스크립트가 매개 변수를 선언하지 않아서 sou가 변경하려고 할 수 있습니다. –
위에서 언급 한 매개 변수를 VSTS 인수 목록의 powershell 스크립트로 보낼 수 있습니까? – PRAVEEN
-parameterName $ parameterValue 그러나 당신의 스크립트는 아직 매개 변수를 선언하지 않았습니다. –