Trying to retrieve publish profile for an appservice/function via below bicep doesn't work and produces an empty string, the Bicep is running with this permissions Microsoft.Web/sites/config/list/Action
and Microsoft.Web/sites/publishxml/Action
:
param appserviceOrFunctionName string
var publishingCredentialsId = resourceId('Microsoft.Web/sites/config', appserviceOrFunctionName, 'publishingCredentials')
# disable-next-line outputs-should-not-contain-secrets
output publish_profile object = list(publishingCredentialsId, '2022-03-01')
Although on another thread on SO, with an unaccepted answer, this doesn't look like it works Retrieve the publishing credentials (publish profile) of App Service with Bicep
How can I retrieve the publish profile XML of a website in Bicep or at least the publish password?
This can be retrieved via Azure CLI with the next command, but I am interested in the pure Bicep.
az webapp deployment list-publishing-profiles --name <webAppName> --resource-group <resourceGroupName> --xml
How can I retrieve the publish profile XML of a website in Bicep or at least the publish password?
By referencing the SO provided by you, I have tried the similar bicep code with few changes in my environment and was able to retrieve the publish profile of an app service without any conflicts.
Firstly, check that the basic authentication is enabled for the app service as it is mandatory to download or get the publish profile details. Go to Configuration
under Settings
and verify the SCM Basic Auth Publishing authentication
and FTP authentication
are set to ON
as shown below.
And also try using the latest version 2024-04-01
when retrieving the profile details if the issue still persists with the older version like 2022-03-01
.
I have executed the below bicep code to get the publishing profile details and was able to be retrieved successfully.
param AppService string = 'appsjah'
var publishingCredentialsIds = resourceId('Microsoft.Web/sites/config', AppService, 'publishingCredentials')
output publishingCredentials object = list(publishingCredentialsIds, '2024-04-01')
If you want to retrieve the publishingUserName
and publishingPassword
specifically then use below outputs
block as given.
output publishingUserName string = list(publishingCredentialsId, '2024-04-01').properties.publishingUserName
output publishingPassword string = list(publishingCredentialsId, '2024-04-01').properties.publishingPassword