현재 Powershell 스크립트를 사용하여 Windows-Azure에서 BlobStorage 내용을 관리하고 있습니다. 텍스트 파일의 내용을 읽고이 내용으로 시작하는 BlobStorage의 파일 이름을 표시하는 스크립트가 필요합니다. BlobStorage에서 텍스트 파일에 지정된 내용으로 시작하는 이름을 나열하는 와일드 카드 검색을 찾고 있습니다.Powershell에서 문자열로 시작하는 BlobStorage의 파일 이름 확인
텍스트 파일의 모든 줄을 검색하고 텍스트 파일의 지정된 내용으로 시작하는 BlobStorage의 파일 이름을 찾는 루프를 생각해 보았습니다.
* 우리는 예를 들어 2 개 TEXTFILE의 행이있는 경우 : *
43345 - sdfssd-42342-sdfsf
32423 - asdsad-23424-dghfs
그리고 파일 이름의를 BlobStorage는 다음과 같습니다
43345 - sdfssd-42342-sdfsf-250.PNG
43345 - sdfssd-42342-sdfsf-650.PNG
92323 - asadad-12342-sdfds-1600.PNG
내가 BlobStorage 파일의 이름으로 TEXTFILE의 ID를 비교하고, 전체를 표시 할 이 ID를 포함하는 BlobStorage의 모든 파일의 파일 이름.
더 여기를 지정 내가를 가정 한 것입니다하려면
foreach (ID in textfile)
{
files = find files in BlobStorage with name that starts with ID (ListBlobsWithPrefix?)
foreach (textfile in files)
{
Write filename to console
}
}
지금까지 내가 관리 한 내 blobstorage에 연결을 그리고 난 이미지 컨테이너에 물방울의 이름을 나열 할 수 있습니다, 작동 . 텍스트 파일을 읽고 콘솔에 내용을 인쇄하는 방법을 모두 확인했습니다. 내가 할 수 없었던 것은 텍스트 파일 ID를 BlobStorage의 Blob 파일 이름과 비교하고 BlobStorage에서 ID로 시작하는 결과를 출력하는 것입니다. 나는 행운이없이 많은 해결책을 시도했다.
지금까지 나는이 코드를 내놓았다 한 :
#Make a connection to my BlobStorage
$SAN = "XX"
$SAK="X"
$creds = New-Object Microsoft.WindowsAzure.StorageCredentialsAccountAndKey($SAN, $SAK)
$client = New-Object Microsoft.WindowsAzure.StorageClient.CloudBlobClient("https://$SAN.blob.core.windows.net",$creds)
$bro = New-Object Microsoft.WindowsAzure.StorageClient.BlobRequestOptions
$bro.UseFlatBlobListing = $true
#Add $images blobcontainer and use flatbloblisting to list blobnames
$imagecontainer = $client.GetBlobDirectoryReference("images")
$images = $imagecontainer.ListBlobs($bro)
#Add textfile and assign it to a variable
$InputFile = Get-Content C:\transcript\hej.txt
#Loop to find everything in the input file and compare it to matching filenames in blobstorage. Return filenames that starts with the ID/contains the ID in the inputfile.
foreach ($ID in Get-Content $InputFile) {
더 도움/솔루션을 주셔서 감사합니다.
코드가 올바른 나열되어 있습니까? 불완전한 for 루프에서 끝내기로되어 있습니까? – Rytmis