LoginSignup
2
2

More than 5 years have passed since last update.

S3ProxyをMicrosoft Azure Blob Storageで使ってみる

Last updated at Posted at 2017-06-23

背景

昨今、特定のクラウドに傾倒するのではなく、マルチクラウドで良いものを選択して使う時代や、マルチクラウド間での冗長なども検討している方もいらしているのではないかと考えております。
そこでストレージ系汎用ミドルウェアを介したAzure Blob Storage試してみます。

早速使ってみました

今回はJvmで動くs3proxyなるものがありましたので、
使ってみることににしました。

対応製品

対応サービス

translation from S3 to Backblaze B2, Google Cloud, Microsoft Azure, or OpenStack Swift
「Microsoft Azure」無論ありますね。

git clone

git clone https://github.com/andrewgaul/s3proxy.git

mvn package

実はこれではunitテストでエラーになるため、jarファイルが作成できません。

mvn package -DskipTests=true

でビルドが完了しました。

$ ls -al target/
total 20688
drwxr-xr-x 1049089 0 6月 23 14:12 ./
drwxr-xr-x 1049089 0 6月 23 14:06 ../
drwxr-xr-x 1049089 0 6月 23 14:10 apidocs/
drwxr-xr-x 1049089 0 6月 23 14:10 archive-tmp/
drwxr-xr-x 1049089 0 6月 23 14:06 classes/
drwxr-xr-x 1049089 0 6月 23 14:06 generated-sources/
drwxr-xr-x 1049089 0 6月 23 14:06 generated-test-sources/
drwxr-xr-x 1049089 0 6月 23 14:10 javadoc-bundle-options/
drwxr-xr-x 1049089 0 6月 23 14:10 maven-archiver/
drwxr-xr-x 1049089 0 6月 23 14:06 maven-status/
-rwxr-xr-x 1049089 10465697 6月 23 14:12 s3proxy*
-rw-r--r-- 1049089 94334 6月 23 14:10 s3proxy-1.6.0-SNAPSHOT.jar
-rw-r--r-- 1049089 10465659 6月 23 14:12 s3proxy-1.6.0-SNAPSHOT-jar-with-dependencies.jar
-rw-r--r-- 1049089 69368 6月 23 14:10 s3proxy-1.6.0-SNAPSHOT-javadoc.jar
-rw-r--r-- 1049089 51660 6月 23 14:12 s3proxy-1.6.0-SNAPSHOT-sources.jar
drwxr-xr-x 1049089 0 6月 23 14:08 surefire-reports/
drwxr-xr-x 1049089 0 6月 23 14:06 test-classes/

s3proxyのバイナリができました。

設定

設定はpropertiesファイル形式で記載します。
例を以下に示します。

s3proxy.authorization=none
s3proxy.endpoint=http://127.0.0.1:8080
jclouds.provider=azureblob
jclouds.identity=<Azure BLOB ストレージ アカウント名>
jclouds.credential=<Azure BLOB アクセスキー>

この設定上記gitリポジトリにはサンプルが書いていないので、s3proxydockerのサイトを参考にしました。
ポイント以下3つ

  1. 「jclouds.provider」の値をazureblobとする
  2. 「jclouds.identity」を<Azure BLOB ストレージ アカウント名>
  3. 「jclouds.credential」を<Azure BLOB アクセスキー>

とすることです。
jcloudsがどうやら肝のようですが、jcloudsは今後調べることにします。

Azure BLOB ストレージ アカウント名Azure BLOB アクセスキーの確認方法を以下に記します。

ストレージアカウント名の確認

image.png
簡単ですね。

実行

今回はWindowsで動かしているので、javaのパラメータで実行します。

Windows users must explicitly invoke java:

java -jar s3proxy --properties s3proxy.conf

実際のコマンド

$ java -jar target/s3proxy --properties s3proxy.conf
[s3proxy] I 06-23 15:50:05.600 main org.eclipse.jetty.util.log:186 |::] Logging initialized @1003ms
[s3proxy] I 06-23 15:50:05.639 main o.eclipse.jetty.server.Server:327 |::] jetty-9.2.z-SNAPSHOT
[s3proxy] I 06-23 15:50:05.797 main o.e.j.server.ServerConnector:266 |::] Started ServerConnector@126945f9{HTTP/1.1}{127.0.0.1:8080}
[s3proxy] I 06-23 15:50:05.797 main o.eclipse.jetty.server.Server:379 |::] Started @1202ms

jettyがどうやらたちあがっているようです。

curl -X PUT http://localhost:8080/samplefolder
image.png

samplefolder のコンテナができています

※ここで注意です。
ストレージのアカウントをアカウント種類を「汎用」にしてください。
「BLOBストレージ」の場合以下のようなエラーになってしまいます。

curl -X PUT http://localhost:8080/samplefolder
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 144 0 144 0 0 122 0 --:--:-- 0:00:01 --:--:-- 122<?xml version='1.0' encoding='UTF-8'?><Error><Code>BadDigest</Code><Message>Bad Request</Message><RequestId>4442587FB7D0A2F9</RequestId></Error>

※※汎用の選択はportal画面では以下のように設定します。BLOBストレージは選択しないようにしてください。

image.pngimage.png

今後

以下のサイトを確認すると、プログラムで呼べるようなので、次回はプログラムからS3Proxy使います。
Using-S3Proxy-in-Java-projects
そして、jcloudsも次々回にはつかってみてAzureでの利用を検討します。

参考URL

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2