powershell-intune-samples
powershell-intune-samples copied to clipboard
Uploading Win32LoB app using Az.Storage cmdlet results in commitFileFailed
Instead of 150+ lines of code for custom upload functions from the sample script, I'm trying to use the native Powershell cmdlets provided by the Az.Storage module for uploading the .intunewin binary. The upload itself works fine, but committing the file later on fails without any further error description.
This seems to be the same behaviour noted in #47, except this time this is 100% Powershell. My code:
if ($currentFileUploadRequestState -like "azureStorageUriRequestSuccess")
{
[System.Uri]$uriObject = $fileUploadRequestResponse.azureStorageUri
$storageAccountName = $uriObject.DnsSafeHost.Split(".")[0]
$sasToken = $uriObject.Query.Substring(1)
$uploadPath = $uriObject.LocalPath.Substring(1)
$container = $uploadPath.Split("/")[0]
$blobPath = $uploadPath.Substring($container.Length+1,$uploadPath.Length - $container.Length-1)
$storageContext = New-AzStorageContext -StorageAccountName $storageAccountName -SasToken $sasToken
$blobUpload = Set-AzStorageBlobContent -File $intunePackageFile -Container $container -Context $storageContext -Blob $blobPath -Force
Write-Host "Upload finished! Details: Name $($blobUpload.Name), ContentType $($blobUpload.ContentType), Length $($blobUpload.Length), LastModified $($blobUpload.LastModified)"
}