Skip to content

Commit 9b3671a

Browse files
authored
Enhance SAS Generation to generate SAS for blob destination (#47)
1 parent 94c3d2d commit 9b3671a

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,13 @@ Invoke [azcopy copy](https://learn.microsoft.com/en-us/azure/storage/common/stor
475475
command in pipeline.
476476

477477
### Inputs
478-
| Name | Description | Optional | Default value |
479-
|---------|:-----------------------------------------------|----------|---------------|
480-
| source | Source directory or SAS url to copy | False | |
481-
| target | Target directory or SAS url | False | |
482-
| put_md5 | If `true` sets `--put-md5` parameter to azcopy | True | True |
478+
| Name | Description | Optional | Default value |
479+
|--------------------|:-----------------------------------------------|----------|---------------|
480+
| source | Source directory or SAS url to copy | False | |
481+
| target | Target directory or SAS url | False | |
482+
| mode | azcopy action mode (copy or sync) | True | copy |
483+
| put_md5 | If `true` sets `--put-md5` parameter to azcopy | True | True |
484+
| delete_destination | azcopy --delete-destination flag | True | False |
483485

484486
### Outputs
485487
No outputs defined
@@ -522,6 +524,7 @@ for a file share, attached to a storage account.
522524
| account_key | Name of the storage account of the share | False | |
523525
| account_name | Key of the storage account of the share | False | |
524526
| expiration_date | Expiration date in format that can be used by the `date` command | True | +10 minutes |
527+
| directory_type | Type of directory (blob or fileshare) | True | fileshare |
525528

526529

527530
**NOTES**:

get_azure_share_sas/action.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ inputs:
2323
required: false
2424
default: "+10 minutes"
2525

26+
directory_type:
27+
description: Type of directory (blob or fileshare)
28+
required: false
29+
default: "fileshare"
2630

2731
outputs:
2832
authorized_destination:
@@ -40,4 +44,5 @@ runs:
4044
ACCOUNT_KEY: ${{ inputs.account_key }}
4145
ACCOUNT_NAME: ${{ inputs.account_name }}
4246
EXPIRATION_DATE: ${{ inputs.expiration_date }}
47+
DIRECTORY_TYPE: ${{ inputs.directory_type }}
4348
id: sas

get_azure_share_sas/get_azure_share_sas.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,19 @@
1616

1717
set -Eeuo pipefail
1818

19-
destination="https://$ACCOUNT_NAME.file.core.windows.net/$DIRECTORY_NAME"
19+
20+
if [[ "$(echo "$DIRECTORY_TYPE" | tr '[:upper:]' '[:lower:]')" == 'fileshare' ]]; then
21+
destination="https://$ACCOUNT_NAME.file.core.windows.net/$DIRECTORY_NAME"
22+
services="f"
23+
elif [[ "$(echo "$DIRECTORY_TYPE" | tr '[:upper:]' '[:lower:]')" == 'blob' ]]; then
24+
destination="https://$ACCOUNT_NAME.blob.core.windows.net/$DIRECTORY_NAME"
25+
services="b"
26+
else
27+
echo "Directory type \"$DIRECTORY_TYPE\" not supported"
28+
exit 1;
29+
fi;
30+
31+
2032

2133
end=$(date -d "$EXPIRATION_DATE" '+%Y-%m-%dT%H:%MZ')
2234
echo "Generating SAS for $destination with expiration date $end"
@@ -28,7 +40,7 @@ sas=$(
2840
--https-only \
2941
--permissions acdlpruw \
3042
--resource-types sco \
31-
--services fb | cut -d'"' -f2
43+
--services "$services" | cut -d'"' -f2
3244
)
3345

3446
authorized_destination="$destination?$sas"

0 commit comments

Comments
 (0)