"Grant-AzSnapshotAccess" fails with "Accessing disk or snapshot with a logical sector size of 4096 requires specifying the file format. Set the fileFormat property to VHDX."
Description
CLI cmdlet "Grant-AzSnapshotAccess", using APIs equal or later than 2023-01-02, fails with "Accessing disk or snapshot with a logical sector size of 4096 requires specifying the file format. Set the fileFormat property to VHDX".
|
PS> $AzSnapshotAccess = @{
ResourceGroupName = $rgName
SnapshotName = $snapshotName
Access = 'Read'
DurationInSecond = 3600
}
PS> Grant-AzSnapshotAccess @AzSnapshotAccess Grant-AzSnapshotAccess: Accessing disk or snapshot with a logical sector size of 4096 requires specifying the file format. Set the fileFormat property to VHDX. ErrorCode: BadRequest ErrorMessage: Accessing disk or snapshot with a logical sector size of 4096 requires specifying the file format. Set the fileFormat property to VHDX. ErrorTarget: StatusCode: 400 ReasonPhrase: Bad Request OperationID : 12d9211a-5723-4bfe-a02c-d7fe6f4a2748 |
When trying to pass the "fileFormat" as parameter for CMDLets, an error is returned saying the 'fileFormat' isn't valid.
|
PS> $AzSnapshotAccess = @{
>> ResourceGroupName = $rgName
>> SnapshotName = $snapshotName
>> Access = 'Read'
>> DurationInSecond = 3600
>> fileFormat = 'VHDX'}
PS> $azSnapshotAccess Name Value fileFormat VHDX Access Read DurationInSecond 3600 SnapshotName $rgName ResourceGroupName $snapshotName PS> Grant-AzSnapshotAccess @AzSnapshotAccess Grant-AzSnapshotAccess: A parameter cannot be found that matches parameter name 'fileFormat'. |
Tested with RESTAPI --> Snapshots - Grant Access - REST API (Azure Compute) | Microsoft Learn The supported api-versions are '2016-04-30-preview, 2017-03-30, 2018-04-01, 2018-06-01, 2018-09-30, 2019-03-01, 2019-07-01, 2019-11-01, 2020-05-01, 2020-06-30, 2020-09-30, 2020-12-01, 2021-04-01, 2021-08-01, 2021-12-01, 2022-03-02, 2022-07-02, 2023-01-02, 2023-04-02, 2023-10-02'
- SUCCESS: I've tried it again with the RestAPI by specifying with the fileFormat set to VHDX in the body and it works with the latest API version 2023-10-02 as well: Snapshots - Grant Access - REST API (Azure Compute) | Microsoft Learn
- {access: "Read",durationInSeconds: "3600",fileFormat: "VHDX"} --
"Grant-AzSnapshotAccess", using APIs equal or later than 2023-01-02, do not offer any parameter to define the "fileFormat".
RestAPI Snapshots - Grant Access - REST API (Azure Compute) | Microsoft Learn accepts the "fileFormat" as parameter. Azure "Grant-AzSnapshotAccess" cmdlet should do the same.
Issue script & Debug output
See above
Environment data
Run in Azure Portal CloudShell
PS> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS CBL-Mariner/Linux
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Module versions
Run in Azure Portal CloudShell
PS> Get-Module Az*
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.15.0 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 7.1.1 Az.Compute {Add-AzImageDataDisk, Add-AzVhd, Add-AzVMAdditionalUnattendContent, Add-AzVMDataDisk…}
Script 7.3.0 Az.Network {Add-AzApplicationGatewayAuthenticationCertificate, Add-AzApplicationGatewayBackendAdd…
Script 6.13.0 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…
Script 6.1.0 Az.Storage {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountManagementPolicyAction, Add-Az…
Script 1.1.3 Az.Tools.Predictor {Disable-AzPredictor, Enable-AzPredictor, Open-AzPredictorSurvey, Send-AzPredictorRati…
Script 0.0.0.10 AzureAD.Standard.Preview {Add-AzureADApplicationOwner, Add-AzureADDeviceRegisteredOwner, Add-AzureADDeviceRegis…
Script 0.9.3 AzurePSDrive
Error output
Run in Azure Portal CloudShell
PS> Resolve-AzError
HistoryId: 11
Message : The term 'PSVersionTable' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
StackTrace : at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes,
SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements,
CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][]
pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception : System.Management.Automation.CommandNotFoundException
InvocationInfo : {}
Line : PSVersionTable
Position : At line:1 char:1
+ PSVersionTable
+ ~~~~~~~~~~~~~~
HistoryId : 11
HistoryId: 10
Message : A parameter cannot be found that matches parameter name 'fileFormat'.
StackTrace : at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(ParameterBindingException
originalBindingException)
at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
--- End of stack trace from previous location ---
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][]
pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception : System.Management.Automation.ParameterBindingException
InvocationInfo : {Grant-AzSnapshotAccess}
Line : Grant-AzSnapshotAccess @AzSnapshotAccess
Position : At line:1 char:24
+ Grant-AzSnapshotAccess @AzSnapshotAccess
+ ~~~~~~~~~~~~~~~~~
HistoryId : 10
HistoryId: 6
RequestId :
Message : Accessing disk or snapshot with a logical sector size of 4096 requires specifying the file format. Set the fileFormat property to VHDX.
ErrorCode: BadRequest
ErrorMessage: Accessing disk or snapshot with a logical sector size of 4096 requires specifying the file format. Set the fileFormat
property to VHDX.
ErrorTarget:
StatusCode: 400
ReasonPhrase: Bad Request
OperationID : 12d9211a-5723-4bfe-a02c-d7fe6f4a2748
ServerMessage :
ServerResponse :
RequestMessage :
InvocationInfo : {Grant-AzSnapshotAccess}
Line : Grant-AzSnapshotAccess @AzSnapshotAccess
Position : At line:1 char:1
+ Grant-AzSnapshotAccess @AzSnapshotAccess
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
StackTrace : at Microsoft.Azure.Commands.Compute.ComputeClientBaseCmdlet.ExecuteClientAction(Action action)
at Microsoft.Azure.Commands.Compute.Automation.GrantAzureRmSnapshotAccess.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
HistoryId : 6
HistoryId: 3
Message : The term 'martinme_repro' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
StackTrace : at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes,
SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements,
CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][]
pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception : System.Management.Automation.CommandNotFoundException
InvocationInfo : {}
Line : ResourceGroupName = martinme_repro
Position : At line:2 char:21
+ ResourceGroupName = martinme_repro
+ ~~~~~~~~~~~~~~
HistoryId : 3
@ushnaarshadkhan Would you mind taking a look at this? Thanks!
Thanks for the feedback! We are looking into this and will provide an update soon.
Thanks for the feedback. I've created a backlog item to track the effort to enable fileFormat support for Grant-AzSnapshotAccess in PowerShell. We will share an ETA once resource is assigned to this ask.