Open dhx10000 opened 5 years ago
Hi,
the error says your function.json file is not containing the request parameter. two reason from the top of my head.
=> the function.json was not copied and is missing the required binding
=> the function app you provisioned is of type V2 (which is the default currently) but the code presented in this sample does not support V2, it's a V1 Code and therefore you need to change the version back to V1.
PLZ - DO NOT PASTE Client Secrets in Error Messages.
the error message in your message above contains tenant id + app id + secret .. PLZ DELETE THIS APP ID.. immediatly as everybody is currently able to delete your groups in your tenant.. if this is your production tenant... your really F*** up..
will look at the error messag in a minute..
thanks, its a test tenant, but I will repost
and to answer your question. the $req parameter is empty - so your functions.json is not correct or seems to be wrong, can you post the function.json your testing with?
ok, I guess that's where my issue is. Maybe I missed those instructions but I did not add any json file so its using the default:
{ "bindings": [ { "authLevel": "function", "type": "httpTrigger", "direction": "in", "name": "Request", "methods": [ "get", "post" ] }, { "type": "http", "direction": "out", "name": "Response" } ] }
Yes - the name of the http trigger binding (which defines the name of the variable for the input) is 'request' .. so the line to read the data needs to reference this as a variable name like: (line 4)
$requestBody = Get-Content $Request -Raw | ConvertFrom-Json
Hi there chwilfing,
I'm having the same issue. I've renamed my variable as stated in your post but I still get the same errors. Also it appears there is no longer a way to deploy a specific v1 application in Azure as they seemed to have merged them. Just curious what I can do to get past this error.
Thank you!
Hi admintgal,
the problem with V1 functions - there is no way to directly create a V1 functions since version V2 with Powershell support is in public preview. you need to create an empty V2 function and 'downgrade' it through the portal to V1 (as shown in the screenshot below)
After downgrading you can create the powershell function with http trigger. this will create the correct function.json and allow you to use
$requestBody` = Get-Content $Req -Raw | ConvertFrom-Json
where
$req
is the name of the http trigger in the function.json (sample:)
{
"bindings": [
{
"name": "req",
"type": "httpTrigger",
"direction": "in",
"authLevel": "function"
},
{
"name": "res",
"type": "http",
"direction": "out"
}
],
"disabled": false
}
The instructions for downgrading your Azure function is as follows:
Does this solve your issue?
chwilfing & dhx10000
Thank you both! This worked like a charm for me!!!
Without sharing confidential detail, can you share a sample functions.json file? I;m still having some problems but I think it has to do with that file not being properly configured.
The Function.json under: https://github.com/martinagrom/Office365Scripts/issues/2#issuecomment-492774499 is a working sample. Are you anything missing?
HI,
this is my exact JSON: { "bindings": [ { "name": "Request", "type": "httpTrigger", "direction": "in", "authLevel": "function", "methods": [ "get", "post" ] }, { "name": "res", "type": "http", "direction": "out" } ], "disabled": false }
Line 4 from your code reads like this: $requestBody = Get-Content $Request -Raw | ConvertFrom-Json
The test JSON is exactly as you have it except of course with my own tenant
When I run the script these are the errors I receive:
Cannot process command because of one or more missing mandatory parameters: Uri.
at Initialize-Authorization,
So I actually ran through both scenarios, 1) creating a new empty function and 2) modifying the parameter mentioned by dhx10000
from there i did not change any of the code except for the following 1) commented out lines 11 and 12 for confidentiality 2) Changed line 51 as the variable was incorrect with what was defined in the app settings. I changed this from appsecret to clientkey 3)Changed line 4 $req variable to match the json file $request 4) Changed line 153 $res variable to match the json file $response
Now runs error free.
The errors I got were referencing empty values where yours is referencing incorrect syntax is appears. Perhaps try recopying the code and making the modifications mentioned above.
I am also facing same issues and have made changes as suggested above and get a Status: 500 Internal Server Error. Please help.
when changing to runtime version 1 I get "Status: 404 Not Found"
I have got a little further now with downgrading Azure Function to 1 and creating new but now get an error about Uri missing: Run Logs Errors and warnings Console Reconnect Copy logs Start Clear Expand 2019-11-14T16:48:44 Welcome, you are now connected to log-streaming service. The default timeout is 2 hours. Change the timeout with the App Setting SCM_LOGSTREAM_TIMEOUT (in seconds).
2019-11-14T16:48:58.081 [Info] Function started (Id=dbd06b2*) 2019-11-14T16:48:58.280 [Info] TenantID: ** AppID: * AppSecret: * 2019-11-14T16:48:58.280 [Info] GroupName: DeathStar EMail: DeathStar UPN: ***** 2019-11-14T16:48:58.452 [Error] : Cannot process command because of one or more missing mandatory parameters: Uri.
at Initialize-Authorization,
at run.ps1: line 101
CategoryInfo : InvalidArgument: (:) [Invoke-RestMethod], ParameterBindingException
FullyQualifiedErrorId : MissingMandatoryParameter,Microsoft.PowerShell.Commands.InvokeRestMethodCommand,run.ps1 2019-11-14T16:48:58.921 [Error] -Uri : The term '-Uri' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at Initialize-Authorization,
at run.ps1: line 101
-Uri
CategoryInfo : ObjectNotFound: (-Uri:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException 2019-11-14T16:48:59.343 [Error] -ContentType : The term '-ContentType' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at Initialize-Authorization,
at run.ps1: line 101
-ContentType
CategoryInfo : ObjectNotFound: (-ContentType:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException 2019-11-14T16:48:59.749 [Error] -Body : The term '-Body' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at Initialize-Authorization,
at run.ps1: line 101
-Body
CategoryInfo : ObjectNotFound: (-Body:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException 2019-11-14T16:48:59.749 [Info] ERROR! Cannot process command because of one or more missing mandatory parameters: Uri. 2019-11-14T16:48:59.749 [Info] [] 2019-11-14T16:48:59.749 [Info] ERROR! Cannot process command because of one or more missing mandatory parameters: Uri. 2019-11-14T16:48:59.766 [Info] ERROR! Cannot process command because of one or more missing mandatory parameters: Uri. 2019-11-14T16:48:59.766 [Info] ERROR! Cannot process command because of one or more missing mandatory parameters: Uri. 2019-11-14T16:48:59.766 [Info] ERROR! Cannot process command because of one or more missing mandatory parameters: Uri. 2019-11-14T16:48:59.843 [Error] : Cannot bind argument to parameter 'FilePath' because it is null.
at run.ps1: line 305
CategoryInfo : InvalidData: (:) [Out-File], ParameterBindingValidationException
FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.OutFileCommand,run.ps1 2019-11-14T16:48:59.843 [Info] CREATED: DeathStar, 2019-11-14T16:48:59.921 [Error] Exception while executing function: Functions.HttpTriggerPowerShell2. Microsoft.Azure.WebJobs.Script: PowerShell script error. System.Management.Automation: Cannot process command because of one or more missing mandatory parameters: Uri. 2019-11-14T16:48:59.984 [Error] Function completed (Failure, Id=dbd06b2a-b067-4f31-b3a9-e203530b5d8d, Duration=1911ms)
Hi I was trying to follow the series:https://blog.atwork.at/post/2017/10/01/Provisioning-an-Office-365-group-with-an-approval-flow-and-Azure-functions-part-2. I copied the provisioning code from GitHub to my Azure function, copied the GroupName and UPN values in the Request Body, ran the script and received the following error:
Exception: No parameter defined in the script or function for the input binding 'Request'.
Stack: at Microsoft.Azure.Functions.PowerShellWorker.AzFunctionInfo..ctor(RpcFunctionMetadata metadata) in C:\projects\azure-functions-powershell-worker\src\FunctionInfo.cs:line 121 at Microsoft.Azure.Functions.PowerShellWorker.FunctionLoader.LoadFunction(FunctionLoadRequest request) in C:\projects\azure-functions-powershell-worker\src\FunctionLoader.cs:line 45 at Microsoft.Azure.Functions.PowerShellWorker.RequestProcessor.ProcessFunctionLoadRequest(StreamingMessage request) in C:\projects\azure-functions-powershell-worker\src\RequestProcessor.cs:line 186