I am trying to do web job creation, if not exist.
for single webapp this line of command worked.
az webapp deployment source config-zip --resource-group "rg1" --name "webapp1" --src "pathfile.zip"
Zip file structure was created as described as in
https://github.com/projectkudu/kudu/wiki/WebJobs.
I can see the webjob created, but when I am putting it in the loop I am getting error.
here is the code I have so far.
# Resource group name........
resourceGroup="rg1"
# Path to the zip file containing the web job
zipFilePath="zipfilepath/file.zip"
# Web job name
webJobName="webjob1"
# Get a list of all web apps within the resource group
webAppNames=$(az webapp list --resource-group $resourceGroup --query "[].name" -o tsv)
# Loop over each web app name
for webAppName in $webAppNames; do
# Check if the web job already exists in the web app
if az webapp webjob triggered list --resource-group $resourceGroup --name $webAppName --query "[?name=='$webJobName']" -o tsv | grep -q "$webJobName"; then
echo "Web job '$webJobName' already exists in web app '$webAppName'. Skipping deployment."
else
echo "Deploying web job '$webJobName' to web app: $webAppName"
az webapp deployment source config-zip --resource-group $resourceGroup --name $webAppName --src $zipFilePath
fi
done
Error
At line:14 char:4
+ for webAppName in "${webAppNames[@]}"; do
+ ~ Missing opening '(' after keyword 'for'. At line:14 char:42
+ for webAppName in "${webAppNames[@]}"; do
+ ~ Missing statement body in do loop.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingOpenParenthesisAfterKeyword