Vielen Dank für Ihren Vorschlag, Perter Pan.
Ich folgte Azure PUT Blob authentication fails in R
Allerdings wird das Skript fehlschlagen. Die Fehlermeldung lautet
error:1411809D:SSL routines:SSL_CHECK_SERVERHELLO_TLSEXT:tls invalid
ecpointformat list
Ich dachte, das Problem zu https-Zugriff im Zusammenhang kann. (ich dies schreibe, weil, wenn für den Zugriff auf Blob Speicher in Azure ML Python-Skript, ich hatte auch Access Azure blog storage from within an Azure ML experiment gefolgt)
Das gleiche Problem, das ich für R gefunden ist Error:1411809D:SSL routines - When trying to make https call from inside R module in AzureML
Also änderte ich die https http. Das Skript versucht jedoch mehrmals, auf den Blob-Speicher zuzugreifen und wird nie ausgeführt. Ich kann die Anzahl der Anfragen im Speicher des Azure-Portals sehr erhöhen.
Mein Code ist eigentlich die ähnlich wie Azure PUT Blob authentication fails in R der Ausnahme, dass die Anforderungs-URL
auf http geändert
Das Skript Schlag ist.
library(httr)
account <- "accountname"
container <- "containrname"
filename <- "test.txt"
key <- "8FS+3i9eXx....r54Gl97F0nVwyDcV7lXbcWhmQ=="
object <- "Hello World"
url <- paste0("http://", account, ".blob.core.windows.net/", container,
"/", filename)
requestdate <- format(Sys.time(),"%a, %d %b %Y %H:%M:%S %Z", tz="GMT")
content_length <- nchar(object, type = "bytes")
signature_string <- paste0("PUT", "\n", # HTTP Verb
"\n", # Content-Encoding
"\n", # Content-Language
content_length, "\n", # Content-Length
"\n", # Content-MD5
"text/plain", "\n", # Content-Type
"\n", # Date
"\n", # If-Modified-Since
"\n", # If-Match
"\n", # If-None-Match
"\n", # If-Unmodified-Since
"\n", # Range
# Here comes the Canonicalized Headers
"x-ms-blob-type:BlockBlob","\n",
"x-ms-date:",requestdate,"\n",
"x-ms-version:2015-02-21","\n",
# Here comes the Canonicalized Resource
"/",account, "/",container,"/", filename)
headerstuff <- add_headers(Authorization=paste0("SharedKey
",account,":",
RCurl::base64(digest::hmac(key =
RCurl::base64Decode(key, mode = "raw"),
object = enc2utf8(signature_string),
algo = "sha256", raw = TRUE))),
`Content-Length` = content_length,
`x-ms-date`= requestdate,
`x-ms-version`= "2015-02-21",
`x-ms-blob-type`="BlockBlob",
`Content-Type`="text/plain")
content(PUT(url, config = headerstuff, body = object, verbose()), as =
"text")