question

RohitKulkarni-6062 avatar image
0 Votes"
RohitKulkarni-6062 asked ·

Powershellscript

Hello Team, I am running the PowerShell script in PowerShell function in Azure .Please refer below the screenshot ![74724-image.png][1] 1.Withoutsaving the script it is working fine.Please refer the screenshot below : ![74649-image.png][2] 2.After saving the script and try to run I am getting error .Please refer the screenshot below : ![74653-image.png][3] [1]: /answers/storage/attachments/74724-image.png [2]: /answers/storage/attachments/74649-image.png [3]: /answers/storage/attachments/74653-image.png

azure-functions
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MayankBargali-MSFT avatar image
0 Votes"
MayankBargali-MSFT answered ·

Hi anonymous user

Welcome to Microsoft Q&A! Thanks for posting the question.

If you check your first screenshot you have written some piece of code that is not saved and when you try to run that the last saved code (default code when you create any trigger) was executed. That is the reason you will see in the output the message as "Hello, Azure. This HTTP triggered function executed successfully." The default code is as below:

 using namespace System.Net
    
 # Input bindings are passed in via param block.
 param($Request, $TriggerMetadata)
    
 # Write to the Azure Functions log stream.
 Write-Host "PowerShell HTTP trigger function processed a request."
    
 # Interact with query parameters or the body of the request.
 $name = $Request.Query.Name
 if (-not $name) {
     $name = $Request.Body.Name
 }
    
 $body = "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
    
 if ($name) {
     $body = "Hello, $name. This HTTP triggered function executed successfully."
 }
    
 # Associate values to output bindings by calling 'Push-OutputBinding'.
 Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
     StatusCode = [HttpStatusCode]::OK
     Body = $body
 })

The error is the expected in your error screenshot as you have removed the param($Request, $TriggerMetadata) to get the metadata and the function couldn't execute and throws 500 error. You can review Azure function HTTP trigger to learn more about configuration and working.

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

anonymous user If you want to communicate with any of the azure services you need to authenticate against azure services. Once you have authenticated you can perform any operation of that resource like creating the file. Sharing one of the discussion where the script is first authenticating the request and then performing operations.


0 Votes 0 ·
VaibhavChaudhari avatar image
0 Votes"
VaibhavChaudhari answered ·

Not sure on this issue but you can think of running PowerShell script in Azure automation as well. It should more easy there and it is also possible to call this Azure automation runbook in data factory if it has to run on schedule


Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav

· 3 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I am also running the script in runbook. But still not able to run the query successfully.

0 Votes 0 ·

Are you trying to create a new file with "hello world" content in ADLS Gen2 here?

0 Votes 0 ·

Yes i am writing the hello world script .And i want to call that runbook in pipeline is it correct .

0 Votes 0 ·