Skip to content

Commit

Permalink
inline script is working
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneHezser committed Jul 5, 2024
1 parent bdb89bf commit 8480627
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
24 changes: 23 additions & 1 deletion avm/ptn/deployment-script/import-image-to-acr/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,29 @@ module imageImport 'br/public:avm/res/resources/deployment-script:0.2.3' = {
storageAccountResourceId: storageAccountResourceId
containerGroupName: '${resourceGroup().name}-infrastructure'
subnetResourceIds: subnetResourceIds
scriptContent: loadTextContent('./scripts/importscript.sh', 'utf-8')
// scriptContent: loadTextContent('./scripts/importscript.sh')
scriptContent: '''#!/bin/bash
set -e
echo "Waiting on RBAC replication ($initialDelay)\n"
sleep $initialDelay
# retry loop to catch errors (usually RBAC delays, but 'Error copying blobs' is also not unheard of)
retryLoopCount=0
until [ $retryLoopCount -ge $retryMax ]
do
echo "Importing Image ($retryLoopCount): $imageName into ACR: $acrName\n"
if [ $overwriteExistingImage = 'true' ]; then
az acr import -n $acrName --source $imageName --force
else
az acr import -n $acrName --source $imageName
fi
sleep $retrySleep
retryLoopCount=$((retryLoopCount+1))
done
echo "done\n"'''
}
}

Expand Down
5 changes: 2 additions & 3 deletions avm/ptn/deployment-script/import-image-to-acr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "4157392410007593041"
"templateHash": "1060505698355810100"
},
"name": "import-image-to-acr",
"description": "This modules deployes an image to an Azure Container Registry.",
Expand Down Expand Up @@ -167,7 +167,6 @@
}
},
"variables": {
"$fxv#0": "#!/bin/bash\nset -e\n\necho 'Waiting on RBAC replication ($initialDelay)'\nsleep $initialDelay\n\n# retry loop to catch errors (usually RBAC delays, but 'Error copying blobs' is also not unheard of)\nretryLoopCount=0\nuntil [ $retryLoopCount -ge $retryMax ]\ndo\n echo 'Importing Image ($retryLoopCount): $imageName into ACR: $acrName'\n if [ $overwriteExistingImage = 'true' ]; then\n az acr import -n $acrName --source $imageName --force && break\n else\n az acr import -n $acrName --source $imageName && break\n fi\n\n sleep $retrySleep\n retryLoopCount=$((retryLoopCount+1))\ndone\n\necho 'done'\n",
"useExistingManagedIdentity": "[greater(length(coalesce(tryGet(parameters('managedIdentities'), 'userAssignedResourcesIds'), createArray())), 0)]"
},
"resources": {
Expand Down Expand Up @@ -335,7 +334,7 @@
"value": "[parameters('subnetResourceIds')]"
},
"scriptContent": {
"value": "[variables('$fxv#0')]"
"value": "#!/bin/bash\n set -e\n\n echo \"Waiting on RBAC replication ($initialDelay)\\n\"\n sleep $initialDelay\n\n # retry loop to catch errors (usually RBAC delays, but 'Error copying blobs' is also not unheard of)\n retryLoopCount=0\n until [ $retryLoopCount -ge $retryMax ]\n do\n echo \"Importing Image ($retryLoopCount): $imageName into ACR: $acrName\\n\"\n if [ $overwriteExistingImage = 'true' ]; then\n az acr import -n $acrName --source $imageName --force\n else\n az acr import -n $acrName --source $imageName\n fi\n\n sleep $retrySleep\n retryLoopCount=$((retryLoopCount+1))\n done\n\n echo \"done\\n\""
}
},
"template": {
Expand Down

0 comments on commit 8480627

Please sign in to comment.