I am trying to access Azure WebApp kudu files from the Azure automation account runbook. The condition from Azure App services is, that it has to Deny all public IP access rule for the Advanced tool site rule with priority 2000 I added another rule with a priority of 100 and allowed with source type as service tag and value as "GuestandHybridManagement". Still, when I run the runbook, it is unable to access the SCM files.
Azure Webapp kudu file access:
To access the SCM files from automation runbook, you need to have a website contributor role
assigned to the managed identity under Automation account >> Identity
as shown below.
Use below script to access the SCM files from a runbook as it worked for me as expected.
connect-AzAccount -Identity
$webAppName = "myapsj"
$rg = "Jahnavi"
$appinfo = Get-AzWebApp -Name $webAppName -ResourceGroupName $rg
$appinfo.EnabledHostNames[1]
$uri = "https://"+$appinfo.EnabledHostNames[1]
$kudu = Invoke-WebRequest -URI $uri
write-output $kudu.content