How to access the publishing credentials of a webs

2019-09-13 04:27发布

问题:

I'm trying to get the publishing credentials of a website using AzureRm and PowerShell using Invoke-AzureRmResourceAction and PowerShell.

In this answer @David Ebbo explains how to do it using ResourceName and ResourceGroupName as parameters of the Invoke-AzureRmResourceAction cmdlet. I've tried that and it works perfectly and the object I get back has an Id property that looks a lot like a ResourceId. I've tried using that Id as the ResourceId parameter and removing ResourceName and ResourceGroupName but I get an error saying the resource doesn't exist.

I'd like to use ResourceId because I need to automate this for a series of Websites in different resource groups and I only have (easy) access to the ResourceId (and the ResourceId of the website looks really similar to the Id of the publishing credentials object I get using ResourceName and ResourceGroupName).

Thanks!

回答1:

It is working fine for me with the following command:

Invoke-AzureRmResourceAction -ResourceId /subscriptions/$sub/resourceGroups/$rg/providers/Microsoft.Web/sites/$sitename/config/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force -Debug