-
Notifications
You must be signed in to change notification settings - Fork 53
bundle and handle Azure PowerShell #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
dfff565
add logic to grab dependencies
TylerLeonhardt 5ba4805
move psdepends logic
TylerLeonhardt f59903e
PSDepends is not a required dependency
TylerLeonhardt 5daeb6b
move comment
TylerLeonhardt 15be657
actually include install deps script
TylerLeonhardt 561473b
fix path
TylerLeonhardt 5d05e52
commit handle Azure authentication
TylerLeonhardt 1601d6f
move WriteAsync out of using
TylerLeonhardt e40ad29
authenticate to azure per-request and address feedback
TylerLeonhardt ea8fbaa
moved Auth to Azure in Worker Init for now
TylerLeonhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"disabled": false, | ||
"bindings": [ | ||
{ | ||
"authLevel": "function", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req", | ||
"methods": [ | ||
"get", | ||
"post" | ||
] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "res" | ||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Trigger the function by running Invoke-RestMethod: | ||
# Get everything: Invoke-RestMethod -Uri http://localhost:7071/api/GetAzureVmHttpTrigger | ||
# Specify parameters: Invoke-RestMethod ` | ||
# -Uri http://localhost:7071/api/MyHttpTrigger?Name=testVm&ResourceGroupName=TESTRESOURCEGROUP | ||
|
||
# Input bindings are passed in via param block. | ||
param($req, $TriggerMetadata) | ||
|
||
$cmdletParameters = $req.Query | ||
|
||
# If the cmdlet fails, we want it to throw an exception | ||
$cmdletParameters.ErrorAction = "Stop" | ||
|
||
try { | ||
# Splat the parameters that were passed in via query parameters | ||
$vms = Get-AzureRmVM @cmdletParameters | ||
$response = [HttpResponseContext]@{ | ||
StatusCode = '200' # OK | ||
Body = ($vms | ConvertTo-Json) | ||
} | ||
} catch { | ||
$response = [HttpResponseContext]@{ | ||
StatusCode = '400' # Bad Request | ||
Body = @{ Exception = $_.Exception } | ||
} | ||
} | ||
|
||
# You associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name res -Value $response |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@{ | ||
# Packaged with the PowerShell Language Worker | ||
'PowerShellGet' = @{ | ||
Version = '1.6.7' | ||
Target = 'src/Modules' | ||
} | ||
'Microsoft.PowerShell.Archive' = @{ | ||
Version = '1.1.0.0' | ||
Target = 'src/Modules' | ||
} | ||
'AzureRM.Netcore' = @{ | ||
Version = '0.13.1' | ||
Target = 'src/Modules' | ||
} | ||
|
||
# Dev dependencies | ||
'Pester' = @{ | ||
Version = 'latest' | ||
Target = 'CurrentUser' | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Copyright (c) Microsoft. All rights reserved. | ||
# Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
# | ||
|
||
$dependencies = Import-PowerShellDataFile "$PSScriptRoot/../src/requirements.psd1" | ||
|
||
foreach ($key in $dependencies.Keys) { | ||
$params = @{ Name = $key } | ||
|
||
if ($dependencies[$key].Version -ne 'latest') { | ||
# Save-Module doesn't have -Version so we have to specify Min and Max | ||
$params.MinimumVersion = $dependencies[$key].Version | ||
$params.MaximumVersion = $dependencies[$key].Version | ||
} | ||
|
||
if($dependencies[$key].Target -eq 'CurrentUser') { | ||
$params.Scope = $dependencies[$key].Target | ||
Install-Module @params | ||
TylerLeonhardt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
$params.Path = $dependencies[$key].Target | ||
if (Test-Path "$($params.Path)/$key") { | ||
Write-Host "'$key' - Module already installed" | ||
} else { | ||
Save-Module @params | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain why we are doing this for every function invocation? Are you expecting the environment variables may change for each function invocation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we talked offline. I will move it to WorkerInit for the demo but also opened #49 for understanding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed.