Skip to content

Commit c8e986c

Browse files
fix: Increase retry attempts and improve error messaging for Azure Blob Storage uploads (microsoft#607)
1 parent 6e20bcc commit c8e986c

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

infra/scripts/copy_kb_files.sh

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,46 +123,54 @@ echo "Uploading files to Azure Blob Storage"
123123
# Using az storage blob upload-batch to upload files with managed identity authentication, as the az storage fs directory upload command is not working with managed identity authentication.
124124
az storage blob upload-batch --account-name "$storageAccount" --destination data/"$extractedFolder1" --source $extractionPath1 --auth-mode login --pattern '*' --overwrite --output none
125125
if [ $? -ne 0 ]; then
126-
retries=3
126+
maxRetries=5
127+
retries=$maxRetries
127128
sleepTime=10
128-
echo "Error: Failed to upload files to Azure Blob Storage. Retrying upload...($((4 - retries)) of 3)"
129+
attempt=1
129130
while [ $retries -gt 0 ]; do
131+
echo "Error: Failed to upload files to Azure Blob Storage. Retrying upload...$attempt of $maxRetries in $sleepTime seconds"
130132
sleep $sleepTime
131133
az storage blob upload-batch --account-name "$storageAccount" --destination data/"$extractedFolder1" --source $extractionPath1 --auth-mode login --pattern '*' --overwrite --output none
132134
if [ $? -eq 0 ]; then
133135
echo "Files uploaded successfully to Azure Blob Storage."
134136
break
135137
else
136138
((retries--))
137-
echo "Retrying upload... ($((4 - retries)) of 3)"
139+
((attempt++))
138140
sleepTime=$((sleepTime * 2))
139-
sleep $sleepTime
140141
fi
141142
done
142-
exit 1
143+
if [ $retries -eq 0 ]; then
144+
echo "Error: Failed to upload files after all retry attempts."
145+
exit 1
146+
fi
143147
else
144148
echo "Files uploaded successfully to Azure Blob Storage."
145149
fi
146150

147151
az storage blob upload-batch --account-name "$storageAccount" --destination data/"$extractedFolder2" --source $extractionPath2 --auth-mode login --pattern '*' --overwrite --output none
148152
if [ $? -ne 0 ]; then
149-
retries=3
153+
maxRetries=5
154+
retries=$maxRetries
155+
attempt=1
150156
sleepTime=10
151-
echo "Error: Failed to upload files to Azure Blob Storage. Retrying upload...($((4 - retries)) of 3)"
152157
while [ $retries -gt 0 ]; do
158+
echo "Error: Failed to upload files to Azure Blob Storage. Retrying upload...$attempt of $maxRetries in $sleepTime seconds"
153159
sleep $sleepTime
154160
az storage blob upload-batch --account-name "$storageAccount" --destination data/"$extractedFolder2" --source $extractionPath2 --auth-mode login --pattern '*' --overwrite --output none
155161
if [ $? -eq 0 ]; then
156162
echo "Files uploaded successfully to Azure Blob Storage."
157163
break
158164
else
159165
((retries--))
160-
echo "Retrying upload... ($((4 - retries)) of 3)"
166+
((attempt++))
161167
sleepTime=$((sleepTime * 2))
162-
sleep $sleepTime
163168
fi
164169
done
165-
exit 1
170+
if [ $retries -eq 0 ]; then
171+
echo "Error: Failed to upload files after all retry attempts."
172+
exit 1
173+
fi
166174
else
167175
echo "Files uploaded successfully to Azure Blob Storage."
168176
fi

0 commit comments

Comments
 (0)