私は、AzureストレージAPIに対して、公開されていないアカウントにリクエストを行い、認証リクエストが必要です。Azure Blobストレージを使用してhttpsでREST APIを公開
私は、ヘッダーのため、このページに従うことをしようとしていた。 https://msdn.microsoft.com/en-us/library/azure/dd179428.aspx
私は単純にこの作業を行うことができません。私はいつも "ResourceNotFound"というエラーが出るので、私はストレージアカウントやコンテナ名を誤って入力しているわけではないので説明できません。また、同じアカウント、コンテナ、およびキーを使用して、Power BIに正常に接続しました。
私が考えることができるのは、Signatureが生成されている可能性があることです。エンコードでは失われてしまう可能性があります(初めてこのようなことをしています)。しかし、 "ResourceNotFound"。リクエスト(R)のコードは次のとおりです。
#azure storage endpoint to hit against
account <- "myaccount"
container <- "mycontainer"
requestProperties <- "comp=list"
endPoint <- paste("https://", account, ".blob.core.windows.net/", sep = "")
endPoint
#[1] "https://myaccount.blob.core.windows.net/"
#date header
timeStamp <- Sys.time()
timeString <- format(timeStamp, format="%y-%m-%d %H:%M:%S", tz="GMT", usetz = TRUE)
timeString <- "Fri, 30 Sep 2016 14:54:30 GMT"
dateHeader <- paste("x-ms-date", timeString, sep = ":")
dateHeader
#[1] "x-ms-date:Fri, 30 Sep 2016 14:54:30 GMT"
#version header
versionHeader <- "x-ms-version:2015-02-21"
#authorization header
requestVerb <- "GET"
authType <- "SharedKey"
azureKey <- "myAccountKey"
newLines <- "\n\n\n\n\n\n\n\n\n\n"
canonicalizedHeaders <- paste(dateHeader,versionHeader, sep = "\n")
#build canonicalized resource
resourceAccount <- paste("/",account, sep = "")
resourceContainer <- paste ("/",container, sep = "")
resource <- paste(resourceAccount, resourceContainer, sep = " ")
canonicalizedResource <- paste(resource, requestProperties, sep = "\n")
canonicalizedResource
#[1] "/myaccount /mycontainer\ncomp=list"
#build authentication signed string
stringToSign <- paste(requestVerb, newLines, canonicalizedHeaders, canonicalizedResource, sep = "\n")
stringToSign <- enc2utf8(stringToSign)
stringToSign
#[1] "GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Fri, 30 Sep 2016 14:54:30 GMT\nx-ms-version:2015-02-21\n/myaccount /mycontainer\ncomp=list"
Signature <- digest::hmac(object = stringToSign, key = azureKey, algo = "sha256", serialize = FALSE)
#authentication header
authorization <- paste(account, Signature, sep = ":")
authorization
#[1] "myaccount:b4761595ea09d0e9d56223bd0a14233bca2b9fc3bb043031586215942f5c6d06"
authHeader <- paste("Authorization:", authType, authorization, sep = " ")
authHeader
#[1] "Authorization: SharedKey myaccount:b4761595ea09d0e9d56223bd0a14233bca2b9fc3bb043031586215942f5c6d06"
#build the actual request
request <- paste(endPoint, requestProperties, sep = "?")
request
#[1] "https://myaccount.blob.core.windows.net/?comp=list"
azureRequest <- httr::GET(request, httr::add_headers(dateHeader, versionHeader, authHeader))
responseContent <- httr::content(azureRequest, as = "text")
responseContent
#[1] "<?xml version=\"1.0\" encoding=\"utf-8\"?><Error><Code>ResourceNotFound</Code><Message>The specified resource does not exist.\nRequestId:b1e87500-0001-0003-6231-1b7598000000\nTime:2016-09-30T15:44:52.3452448Z</Message></Error>"
リクエストを生成中に何か不足していますか? REST API経由でのアクセスを許可するには、アカウントで何かする必要がありますか?
MSは、デモの目的で公に利用できる認証キーを持つ仮のアカウントを提供していないのですか?それ以外の場合は、Azure以外の残りのユーザーが回答をテストすることができないため、Azure固有のフォーラムに行ってください。 –
あなたの本当のSharedKeyではないことを願っています – Paparazzi
パスにコンテナを入れてみてください。例えばhttp:// .blob.core.windows.net/mycontainer –
Paparazzi