3
$this->blobClient = ServicesBuilder::getInstance()
                                ->createBlobService($azureString);

$properties = $this->blobClient->getServiceProperties();

How can i change the default service version of microsoft azure?

Currently it is set at 2009-09-19. i want to change it to 2012-02-12.

Thanks.

malacdon
  • 143
  • 9

2 Answers2

8

To expand on Aaron Chen's answer, you can actually set the default service version permanently, so that you don't have to provide the x-ms-version request header to get newer features for public requests (like "Accept-Ranges: bytes" header for example). It is a bit of a hassle though, because almost no SDK actually supports setting this property. What worked for me is to use the following PowerShell code. It's for Windows only (the DotNetCore-Azure modules for other platforms do not support that either), but it works using the Cloud Shell within Azure Portal if you don't have access to a Windows environment.

Within Cloud Shell:

PS Azure:\> $ctx = New-AzureStorageContext -StorageAccountName <account-name> -StorageAccountKey <key>
Azure:\
PS Azure:\> Update-AzureStorageServiceProperty -ServiceType Blob -DefaultServiceVersion 2017-07-29 -Context $ctx

This will set the default version of the storage account's service to 2017-07-29 (the newest at the time of this writing) for all requests which don't provide their own x-ms-version header. See this list for an overview of the different versions available.

Within a Windows PowerShell environment you have to install the Azure modules as well:

As an admin:

Install-Module -Name AzureRM -AllowClobber
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

As a user

Import-Module Azure.Storage
$ctx = New-AzureStorageContext -StorageAccountName <account-name> -StorageAccountKey <key>
Update-AzureStorageServiceProperty -ServiceType Blob -DefaultServiceVersion 2017-07-29 -Context $ctx 
maetthu
  • 641
  • 8
  • 10
0

You mean STORAGE_API_LATEST_VERSION? It is set to 2015-04-05 in the latest SDK version (v 0.14.0).

However, you can change it at:

vendor\microsoft\azure-storage\src\Common\Internal\Resources.php 

EDIT:

Per Azure's documentation,

If a request to the Blob service does not specify the x-ms-version header, and the default version for the service has not been set using Set Blob Service Properties, then the earliest version of the Blob service is used to process the request. However, if the container was made public with a Set Container ACL operation performed using version 2009-09-19 or newer, then the request is processed using version 2009-09-19.

So you can specify the x-ms-version header to change DefaultServiceVersion via Postman.

enter image description here

Aaron Chen
  • 9,835
  • 1
  • 16
  • 28
  • Hi. Mr. Aarron. Thanks for the reply. It is set to 2015-04-05. however when i access the audio using postman. **x-ms-version** is 2009-09-19. is there any way to change DefaultServiceVersion. I think azure uses the oldest one which is 2009-09-19 – malacdon Apr 11 '17 at 10:21