Java 无法将图像上载到azure blob存储

Java 无法将图像上载到azure blob存储,java,android,azure,azure-storage-blobs,Java,Android,Azure,Azure Storage Blobs,我正在尝试将图像上载到azure blob存储。我正在使用java SDK for azure。我已经引用了这些库。这是我的密码 public void uploadImage(View view) { // Do something in response to button click try { String storageConnectionString = RoleEnvironment.getConfigurati

我正在尝试将图像上载到azure blob存储。我正在使用java SDK for azure。我已经引用了这些库。这是我的密码

public void uploadImage(View view) {
    // Do something in response to button click
    try
     {
     String storageConnectionString = 
                RoleEnvironment.getConfigurationSettings().get("StorageConnectionString");
        CloudStorageAccount storageAccount =
                CloudStorageAccount.parse(storageConnectionString);

            // Create the blob client
            CloudBlobClient blobClient = storageAccount.createCloudBlobClient();

            // Retrieve reference to a previously created container
            CloudBlobContainer container = blobClient.getContainerReference("classifieds");

            // Create or overwrite the "myimage.jpg" blob with contents from a local file
            CloudBlockBlob blob = container.getBlockBlobReference("myimage.png");
             InputStream ims = getAssets().open("myimage.png");

            int len =ims.available();
            blob.upload(ims,(long)ims.available());
     }
     catch(Exception ex)
     {
         System.out.println(ex);
     }
}
这是我的错误日志

05-05 15:34:25.295:E/Trace(5195):打开跟踪文件时出错:无此错误 文件或目录(2)05-05 15:34:26.105:I/dalvikvm(5195):无法 查找方法 com.microsoft.windowsazure.serviceruntime.RoleEnvironment.getConfigurationSettings, 引用自方法 com.example.azuresample.MainActivity.uploadImage 05-05 15:34:26.105: W/dalvikvm(5195):VFY:无法解析静态方法8441: Lcom/microsoft/windowsazure/serviceruntime/RoleEnvironment;。getConfigurationSettings ()Ljava/util/Map;05-05 15:34:26.105:D/dalvikvm(5195):VFY:更换 操作码0x71在0x0000 05-05 15:34:26.550:D/gralloc_金鱼(5195): 检测到没有GPU仿真的仿真器。05-05 15:34:34.254: D/AndroidRuntime(5195):关闭VM 05-05 15:34:34.254: W/dalvikvm(5195):threadid=1:线程以未捕获异常退出 (组=0x40a13300)05-05 15:34:34.285:E/AndroidRuntime(5195):致命 例外情况:主要


当您的代码作为
云服务运行时,您只能使用
RoleEnvironment
类。由于您正在Android应用程序中运行代码,因此该类对您不可用

如果连接设置在配置文件中,则可能需要使用其他方法来读取该配置文件