2017-07-14 32 views
3

我可以使用PowerShell cmdlet Get-AzureRMResource列出所有Azure資源。如何列出Azure功能應用程序中的所有功能

是否有一個需要ResourceGroupNameSiteName的cmdlet,它會返回該「Site」中的所有功能。

或者,我可以使用cmdlet的組合來獲取這些詳細信息。

+0

你嘗試類似的信息(未測試)'GET-AzureRMResource -ResourceGroupName $ resourceGroupName -ResourceType Microsoft.Web /網站/ functions' – Hackerman

+0

呀,沒有結果返回。 –

回答

2

至於法比奧Cavalcante的說,Azure的PowerShell不支持此功能,您可以使用REST API來獲取它可以使用ListFunctions API。下面是一個如何使用PowerShell獲取函數的示例。

#get token 
$TENANTID="<tenantid>" 
$APPID="<application id>" 
$PASSWORD="<app password>" 
$result=Invoke-RestMethod -Uri https://login.microsoftonline.com/$TENANTID/oauth2/token?api-version=1.0 -Method Post -Body @{"grant_type" = "client_credentials"; "resource" = "https://management.core.windows.net/"; "client_id" = "$APPID"; "client_secret" = "$PASSWORD" } 
$token=$result.access_token 

##set Header 
[email protected]{ 
    'authorization'="Bearer $token" 
    'host'="management.azure.com" 
} 

$functions = Invoke-RestMethod -Uri "https://management.azure.com/subscriptions/<subscriptions id>/resourceGroups/<group name>/providers/Microsoft.Web/sites/<function name>/functions?api-version=2015-08-01" -Headers $Headers -ContentType "application/json" -Method GET 

$functions.value 

enter image description here

+0

我會試試這個。法比奧給出的鏈接,我無法去工作,並試圖用'scm'端點來使用它們。 這個「工作流程」可能會封裝成PS函數嗎? –

+0

Doug,你能否通過提供的鏈接澄清哪些不適合你? –

+0

我在適當的替換中使用Invoke-RestMethod提供的鏈接嘗試了「uri」。我試過Get-AzureRmResource -ResourceId。我也嘗試了Invoke-AzureRmResourceAction,解析出參數的URI。 –

3

不是PowerShell命令,但你所描述的here

0

這是可能的使用Get-AzureRmResource cmdlet的。

$Params = @{ 
    ResourceGroupName = $ResourceGroupName 
    ResourceType  = 'Microsoft.Web/sites/functions' 
    ResourceName  = $AppName 
    ApiVersion  = '2015-08-01' 
} 
Get-AzureRmResource @Params 
相關問題