Check if file exists on blob storage with Azure functions

前端 未结 4 1259
走了就别回头了
走了就别回头了 2021-01-25 01:28

Based on https://ppolyzos.com/2016/12/30/resize-images-using-azure-functions/ I have the following C# code to resize an image using Azure Functions.

#r \"Microso         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-25 02:24

    Java version for the same ( using the new v12 SDK )

    This uses the Shared Key Credential authorization, which is the account access key.

    StorageSharedKeyCredential credential = new StorageSharedKeyCredential(accountName, accountKey);
    String endpoint = String.format(Locale.ROOT, "https://%s.blob.core.windows.net", accountName);
    BlobServiceClient storageClient = new BlobServiceClientBuilder().credential(credential)
                                          .endpoint(endpoint).buildClient();
    
    BlobContainerClient container = storageClient.getBlobContainerClient(containerName)
    if ( container.exists() ) {
       // perform operation when container exists 
    }         
    

提交回复
热议问题