'Azure Functions Error Message: Method not allowed in this pricing tier

I have an azure function that was developed to automate interactions with API Management.

So upon Http Trigger, it would create an api management user.

This was with the Developer tier and everything worked fine - I had tested it and everything.

enter image description here

Since switching from Developer tier to Consumption tier, I am now receiving the following error during the function.

[6/19/2020 2:37:28 AM] ERROR: New-AzApiManagementUser : 
[6/19/2020 2:37:28 AM] Error Code: MethodNotAllowedInPricingTier
[6/19/2020 2:37:28 AM] Error Message: Method not allowed in this pricing tier
[6/19/2020 2:37:28 AM] Request Id: d6112a6a-c7ab-4648-85f6-74518c2a1351
[6/19/2020 2:37:28 AM]
[6/19/2020 2:37:28 AM] At C:\Users\*******\AzureProjects\course_api_mgmt\course_api_mgmt\run.ps1:48 char:13
[6/19/2020 2:37:28 AM] +     $user = New-AzApiManagementUser -Context $context -FirstName $use ...
[6/19/2020 2:37:28 AM] +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[6/19/2020 2:37:28 AM] + CategoryInfo          : CloseError: (Microsoft.Azure.Man\u2026ase.ExecuteCmdlet():ErrorResponseException) [New-AzApiManagementUser], Exception
[6/19/2020 2:37:28 AM] + FullyQualifiedErrorId : Operation returned an invalid status code 'BadRequest',Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.NewAzureApiManagementUser
[6/19/2020 2:37:28 AM]  
[6/19/2020 2:37:28 AM] Script stack trace:
[6/19/2020 2:37:28 AM]    at <ScriptBlock>, C:\Users\*******\AzureProjects\course_api_mgmt\course_api_mgmt\run.ps1: line 48
[6/19/2020 2:37:28 AM]
[6/19/2020 2:37:28 AM] System.Exception: 
[6/19/2020 2:37:28 AM] Error Code: MethodNotAllowedInPricingTier
[6/19/2020 2:37:28 AM] Error Message: Method not allowed in this pricing tier
[6/19/2020 2:37:28 AM] Request Id: d6112a6a-c7ab-4648-85f6-74518c2a1351
[6/19/2020 2:37:28 AM]
[6/19/2020 2:37:28 AM]
[6/19/2020 2:37:28 AM]
[6/19/2020 2:37:28 AM] Result: ERROR: New-AzApiManagementUser : 
[6/19/2020 2:37:28 AM] Error Code: MethodNotAllowedInPricingTier
[6/19/2020 2:37:28 AM] Error Message: Method not allowed in this pricing tier
[6/19/2020 2:37:28 AM] Request Id: d6112a6a-c7ab-4648-85f6-74518c2a1351
[6/19/2020 2:37:28 AM]
[6/19/2020 2:37:28 AM] At C:\Users\*******\AzureProjects\course_api_mgmt\course_api_mgmt\run.ps1:48 char:13
[6/19/2020 2:37:28 AM] +     $user = New-AzApiManagementUser -Context $context -FirstName $use ...
[6/19/2020 2:37:28 AM] +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[6/19/2020 2:37:28 AM] + CategoryInfo          : CloseError: (Microsoft.Azure.Man\u2026ase.ExecuteCmdlet():ErrorResponseException) [New-AzApiManagementUser], Exception
[6/19/2020 2:37:28 AM] + FullyQualifiedErrorId : Operation returned an invalid status code 'BadRequest',Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.NewAzureApiManagementUser
[6/19/2020 2:37:28 AM]  
[6/19/2020 2:37:28 AM] Script stack trace:
[6/19/2020 2:37:28 AM]    at <ScriptBlock>, C:\Users\*******\AzureProjects\course_api_mgmt\course_api_mgmt\run.ps1: line 48
[6/19/2020 2:37:28 AM]
[6/19/2020 2:37:28 AM] System.Exception: 
[6/19/2020 2:37:28 AM] Error Code: MethodNotAllowedInPricingTier
[6/19/2020 2:37:28 AM] Error Message: Method not allowed in this pricing tier
[6/19/2020 2:37:28 AM] Request Id: d6112a6a-c7ab-4648-85f6-74518c2a1351
[6/19/2020 2:37:28 AM]
[6/19/2020 2:37:28 AM]
[6/19/2020 2:37:28 AM]
Exception: 
[6/19/2020 2:37:28 AM] Error Code: MethodNotAllowedInPricingTier
[6/19/2020 2:37:28 AM] Error Message: Method not allowed in this pricing tier
[6/19/2020 2:37:28 AM] Request Id: d6112a6a-c7ab-4648-85f6-74518c2a1351
[6/19/2020 2:37:28 AM]
Stack: .
[6/19/2020 2:37:29 AM] INFORMATION: 
[6/19/2020 2:37:29 AM] ERROR: New-AzApiManagementSubscription : Cannot validate argument on parameter 'UserId'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
[6/19/2020 2:37:29 AM] At C:\Users\*******\AzureProjects\course_api_mgmt\course_api_mgmt\run.ps1:61 char:71
[6/19/2020 2:37:29 AM] + ... -AzApiManagementSubscription -Context $context -UserId $user.UserId `
[6/19/2020 2:37:29 AM] +                                                            ~~~~~~~~~~~~
[6/19/2020 2:37:29 AM] + CategoryInfo          : InvalidData: (:) [New-AzApiManagementSubscription], ParameterBindingValidationException
[6/19/2020 2:37:29 AM] + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.NewAzureApiManagementSubscription
[6/19/2020 2:37:29 AM]  
[6/19/2020 2:37:29 AM] Script stack trace:
[6/19/2020 2:37:29 AM]    at <ScriptBlock>, C:\Users\*******\AzureProjects\course_api_mgmt\course_api_mgmt\run.ps1: line 61
[6/19/2020 2:37:29 AM]
[6/19/2020 2:37:29 AM] System.Management.Automation.ParameterBindingValidationException: Cannot validate argument on parameter 'UserId'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
[6/19/2020 2:37:29 AM]    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags
flags)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindParameters(UInt32 parameterSets, Collection`1 arguments)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
[6/19/2020 2:37:29 AM] --- End of stack trace from previous location where exception was thrown ---
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
[6/19/2020 2:37:29 AM]
[6/19/2020 2:37:29 AM] Inner exception: System.Management.Automation.ValidationMetadataException: The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
[6/19/2020 2:37:29 AM]    at System.Management.Automation.ValidateNotNullOrEmptyAttribute.Validate(Object arguments, EngineIntrinsics engineIntrinsics)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
[6/19/2020 2:37:29 AM]
[6/19/2020 2:37:29 AM]
[6/19/2020 2:37:29 AM] Result: ERROR: New-AzApiManagementSubscription : Cannot validate argument on parameter 'UserId'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
[6/19/2020 2:37:29 AM] At C:\Users\*******\AzureProjects\course_api_mgmt\course_api_mgmt\run.ps1:61 char:71
[6/19/2020 2:37:29 AM] + ... -AzApiManagementSubscription -Context $context -UserId $user.UserId `
[6/19/2020 2:37:29 AM] +                                                            ~~~~~~~~~~~~
[6/19/2020 2:37:29 AM] + CategoryInfo          : InvalidData: (:) [New-AzApiManagementSubscription], ParameterBindingValidationException
[6/19/2020 2:37:29 AM] + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands.NewAzureApiManagementSubscription
[6/19/2020 2:37:29 AM]  
[6/19/2020 2:37:29 AM] Script stack trace:
[6/19/2020 2:37:29 AM]    at <ScriptBlock>, C:\Users\Aubrey\AzureProjects\course_api_mgmt\course_api_mgmt\run.ps1: line 61
[6/19/2020 2:37:29 AM]
[6/19/2020 2:37:29 AM] System.Management.Automation.ParameterBindingValidationException: Cannot validate argument on parameter 'UserId'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
[6/19/2020 2:37:29 AM]    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags
flags)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindParameters(UInt32 parameterSets, Collection`1 arguments)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
[6/19/2020 2:37:29 AM] --- End of stack trace from previous location where exception was thrown ---
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
[6/19/2020 2:37:29 AM]
[6/19/2020 2:37:29 AM] Inner exception: System.Management.Automation.ValidationMetadataException: The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
[6/19/2020 2:37:29 AM]    at System.Management.Automation.ValidateNotNullOrEmptyAttribute.Validate(Object arguments, EngineIntrinsics engineIntrinsics)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
[6/19/2020 2:37:29 AM]
[6/19/2020 2:37:29 AM]
Exception: Cannot validate argument on parameter 'UserId'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
Stack:    at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags
flags)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindParameters(UInt32 parameterSets, Collection`1 arguments)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
[6/19/2020 2:37:29 AM] --- End of stack trace from previous location where exception was thrown ---
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
[6/19/2020 2:37:29 AM]    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame).
[6/19/2020 2:37:29 AM] OUTPUT: 
[6/19/2020 2:37:30 AM] Executed 'Functions.course_api_mgmt' (Failed, Id=e500bbdd-bac7-49cc-9076-5ff11c8d440c)
[6/19/2020 2:37:30 AM] System.Private.CoreLib: Exception while executing function: Functions.course_api_mgmt. System.Private.CoreLib: Result: Failure
Exception: Object reference not set to an instance of an object.
Stack:    at Microsoft.Azure.Functions.PowerShellWorker.Utility.TypeExtensions.DeriveContentType(HttpResponseContext httpResponseContext, RpcHttp rpcHttp) in C:\projects\azure-functions-powershell-worker\src\Utility\TypeExtensions.cs:line 196
[6/19/2020 2:37:30 AM]    at Microsoft.Azure.Functions.PowerShellWorker.Utility.TypeExtensions.ToRpcHttp(HttpResponseContext httpResponseContext) in C:\projects\azure-functions-powershell-worker\src\Utility\TypeExtensions.cs:line 188
[6/19/2020 2:37:30 AM]    at Microsoft.Azure.Functions.PowerShellWorker.Utility.TypeExtensions.ToTypedData(Object value) in C:\projects\azure-functions-powershell-worker\src\Utility\TypeExtensions.cs:line 242
[6/19/2020 2:37:30 AM]    at Microsoft.Azure.Functions.PowerShellWorker.RequestProcessor.BindOutputFromResult(InvocationResponse response, AzFunctionInfo functionInfo, Hashtable results) in C:\projects\azure-functions-powershell-worker\src\RequestProcessor.cs:line 466
[6/19/2020 2:37:30 AM]    at Microsoft.Azure.Functions.PowerShellWorker.RequestProcessor.ProcessInvocationRequestImpl(StreamingMessage request, AzFunctionInfo functionInfo, PowerShellManager psManager, FunctionInvocationPerformanceStopwatch stopwatch) in C:\projects\azure-functions-powershell-worker\src\RequestProcessor.cs:line 306.

This wasn't something I noticed when looking at the differences between tiers when I decided to switch, but the error message seems pretty straightforward. Can someone confirm that I literally cannot run the command New-AzApiManagementUser in the context of a consumption tier API Management instance?

And if not, is there any way of automating the creation of API Management users in Consumption tier?



Solution 1:[1]

No, you cannot. According to the documentation, "Direct management API" is not supported for consumption tier.

https://docs.microsoft.com/en-us/azure/api-management/api-management-features

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jakub Jenis