none
Upload file to Azure shared storage

    Question

  • Hi All,

    I am trying to upload file using  below script

    $StorageAccountName='vijayedispheredisks'

    #Save the storage account key

    $StorageAccountKey = (Get-AzureStorageKey -StorageAccountName $StorageAccountName).Primary

    $ctx = New-AzureStorageContext -StorageAccountName $StorageAccountName ` -StorageAccountKey $StorageAccountKey

    $s = New-AzureStorageShare $filesharename –Context $ctx # to create new file share

    $FilePath = 'd:\ll.txt'

    $BlobName = 'll2.txt'

    $storageContainer | Set-AzureStorageFileContent –Source $FilePath –Share $s

     

    Which is returning error

     

    PS D:\> D:\test.ps1

    Get-AzureStorageKey : No default subscription has been designated. Use Select-AzureSubscription -Default

    <subscriptionName> to set the default subscription.

    At D:\test.ps1:6 char:23

    + ... countKey = (Get-AzureStorageKey -StorageAccountName $StorageAccountNa ...

    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : CloseError: (:) [Get-AzureStorageKey], ApplicationException

        + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.StorageServices.GetAzureStor

       ageKeyCommand

    New-AzureStorageContext : Cannot validate argument on parameter 'StorageAccountKey'. The argument is null or

    empty. Provide an argument that is not null or empty, and then try the command again.

    At D:\test.ps1:7 char:93

    + ... countName $StorageAccountName ` -StorageAccountKey $StorageAccountKey

    +                                                        ~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : InvalidData: (:) [New-AzureStorageContext], ParameterBindingValidationExceptio

       n

        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.WindowsAzure.Commands.Storage.Commo

       n.Cmdlet.NewAzureStorageContext

    New-AzureStorageShare : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide

    an argument that is not null or empty, and then try the command again.

    At D:\test.ps1:8 char:28

    + $s = New-AzureStorageShare $filesharename –Context $ctx # to create n ...

    +                            ~~~~~~~~~~~~~~

        + CategoryInfo          : InvalidData: (:) [New-AzureStorageShare], ParameterBindingValidationException

        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.WindowsAzure.Commands.Storage.File.

       Cmdlet.NewAzureStorageShare

    Set-AzureStorageFileContent : Cannot validate argument on parameter 'Share'. The argument is null. Provide a

    valid value for the argument, and then try running the command again.

    At D:\test.ps1:11 char:74

    + ... geContainer | Set-AzureStorageFileContent –Source $FilePath –Share $s

    +                                                                        ~~

        + CategoryInfo          : InvalidData: (:) [Set-AzureStorageFileContent], ParameterBindingValidationExce

       ption

        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.WindowsAzure.Commands.Storage.File.

       Cmdlet.SetAzureStorageFileContent

     

     

    When I run script

     

    Select-AzureSubscription -Default -SubscriptionName  "Visual Studio Enterprise VIJAY" 

     

    Select-AzureSubscription : The subscription name Visual Studio Enterprise VIJAY doesn't exist.

    Parameter name: name

    At line:1 char:1

    + Select-AzureSubscription -Default -SubscriptionName  "Visual Studio E ...

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : CloseError: (:) [Select-AzureSubscription], ArgumentException

        + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.SelectAzureSubscriptionCommand

    whenever subscription name "Visual Studio Enterprise VIJAY" is existing.

    Please suggest how this problem can be fixed?

    Thanks in advance,

    Vijay Singh

    Monday, April 24, 2017 5:37 AM

All replies