Skip to content

Commit fb7b743

Browse files
lunnyyp05327
andauthored
Azure blob storage support (#30995)
This PR implemented object storages(LFS/Packages/Attachments and etc.) for Azure Blob Storage. It depends on azure official golang SDK and can support both the azure blob storage cloud service and azurite mock server. Replace #25458 Fix #22527 - [x] CI Tests - [x] integration test, MSSQL integration tests will now based on azureblob - [x] unit test - [x] CLI Migrate Storage - [x] Documentation for configuration added ------ TODO (other PRs): - [ ] Improve performance of `blob download`. --------- Co-authored-by: yp05327 <[email protected]>
1 parent 015efcd commit fb7b743

31 files changed

+780
-56
lines changed

.devcontainer/devcontainer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"ms-azuretools.vscode-docker",
2727
"vitest.explorer",
2828
"qwtel.sqlite-viewer",
29-
"GitHub.vscode-pull-request-github"
29+
"GitHub.vscode-pull-request-github",
30+
"Azurite.azurite"
3031
]
3132
}
3233
},

.github/workflows/pull-db-tests.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,18 @@ jobs:
119119
MINIO_SECRET_KEY: 12345678
120120
ports:
121121
- "9000:9000"
122+
devstoreaccount1.azurite.local: # https://github.com/Azure/Azurite/issues/1583
123+
image: mcr.microsoft.com/azure-storage/azurite:latest
124+
ports:
125+
- 10000:10000
122126
steps:
123127
- uses: actions/checkout@v4
124128
- uses: actions/setup-go@v5
125129
with:
126130
go-version-file: go.mod
127131
check-latest: true
128132
- name: Add hosts to /etc/hosts
129-
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql elasticsearch meilisearch smtpimap" | sudo tee -a /etc/hosts'
133+
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 minio devstoreaccount1.azurite.local mysql elasticsearch meilisearch smtpimap" | sudo tee -a /etc/hosts'
130134
- run: make deps-backend
131135
- run: make backend
132136
env:
@@ -204,14 +208,18 @@ jobs:
204208
SA_PASSWORD: MwantsaSecurePassword1
205209
ports:
206210
- "1433:1433"
211+
devstoreaccount1.azurite.local: # https://github.com/Azure/Azurite/issues/1583
212+
image: mcr.microsoft.com/azure-storage/azurite:latest
213+
ports:
214+
- 10000:10000
207215
steps:
208216
- uses: actions/checkout@v4
209217
- uses: actions/setup-go@v5
210218
with:
211219
go-version-file: go.mod
212220
check-latest: true
213221
- name: Add hosts to /etc/hosts
214-
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mssql" | sudo tee -a /etc/hosts'
222+
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mssql devstoreaccount1.azurite.local" | sudo tee -a /etc/hosts'
215223
- run: make deps-backend
216224
- run: make backend
217225
env:

assets/go-licenses.json

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/migrate_storage.go

+40-1
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ var CmdMigrateStorage = &cli.Command{
4040
Name: "storage",
4141
Aliases: []string{"s"},
4242
Value: "",
43-
Usage: "New storage type: local (default) or minio",
43+
Usage: "New storage type: local (default), minio or azureblob",
4444
},
4545
&cli.StringFlag{
4646
Name: "path",
4747
Aliases: []string{"p"},
4848
Value: "",
4949
Usage: "New storage placement if store is local (leave blank for default)",
5050
},
51+
// Minio Storage special configurations
5152
&cli.StringFlag{
5253
Name: "minio-endpoint",
5354
Value: "",
@@ -96,6 +97,32 @@ var CmdMigrateStorage = &cli.Command{
9697
Value: "",
9798
Usage: "Minio bucket lookup type",
9899
},
100+
// Azure Blob Storage special configurations
101+
&cli.StringFlag{
102+
Name: "azureblob-endpoint",
103+
Value: "",
104+
Usage: "Azure Blob storage endpoint",
105+
},
106+
&cli.StringFlag{
107+
Name: "azureblob-account-name",
108+
Value: "",
109+
Usage: "Azure Blob storage account name",
110+
},
111+
&cli.StringFlag{
112+
Name: "azureblob-account-key",
113+
Value: "",
114+
Usage: "Azure Blob storage account key",
115+
},
116+
&cli.StringFlag{
117+
Name: "azureblob-container",
118+
Value: "",
119+
Usage: "Azure Blob storage container",
120+
},
121+
&cli.StringFlag{
122+
Name: "azureblob-base-path",
123+
Value: "",
124+
Usage: "Azure Blob storage base path",
125+
},
99126
},
100127
}
101128

@@ -228,6 +255,18 @@ func runMigrateStorage(ctx *cli.Context) error {
228255
BucketLookUpType: ctx.String("minio-bucket-lookup-type"),
229256
},
230257
})
258+
case string(setting.AzureBlobStorageType):
259+
dstStorage, err = storage.NewAzureBlobStorage(
260+
stdCtx,
261+
&setting.Storage{
262+
AzureBlobConfig: setting.AzureBlobStorageConfig{
263+
Endpoint: ctx.String("azureblob-endpoint"),
264+
AccountName: ctx.String("azureblob-account-name"),
265+
AccountKey: ctx.String("azureblob-account-key"),
266+
Container: ctx.String("azureblob-container"),
267+
BasePath: ctx.String("azureblob-base-path"),
268+
},
269+
})
231270
default:
232271
return fmt.Errorf("unsupported storage type: %s", ctx.String("storage"))
233272
}

0 commit comments

Comments
 (0)