From 848062780bd3c37fe508a3026b780e6e508c698e Mon Sep 17 00:00:00 2001 From: ReneHezser Date: Fri, 5 Jul 2024 17:17:39 +0200 Subject: [PATCH] inline script is working --- .../import-image-to-acr/main.bicep | 24 ++++++++++++++++++- .../import-image-to-acr/main.json | 5 ++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/avm/ptn/deployment-script/import-image-to-acr/main.bicep b/avm/ptn/deployment-script/import-image-to-acr/main.bicep index c97473ca27..824d199707 100644 --- a/avm/ptn/deployment-script/import-image-to-acr/main.bicep +++ b/avm/ptn/deployment-script/import-image-to-acr/main.bicep @@ -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"''' } } diff --git a/avm/ptn/deployment-script/import-image-to-acr/main.json b/avm/ptn/deployment-script/import-image-to-acr/main.json index e300e3ae59..091b04cf33 100644 --- a/avm/ptn/deployment-script/import-image-to-acr/main.json +++ b/avm/ptn/deployment-script/import-image-to-acr/main.json @@ -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.", @@ -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": { @@ -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": {