Help using New-AzContainerInstanceVolumeMountObject for mounting Azure file share to container.

Amerman, Richard 6 Reputation points
2021-08-30T06:24:12.38+00:00

What I'm actually trying to do is regularly run an azcopy command to copy files from a file share account to a blob account.

I'm primarily using the following:
https://charbelnemnom.com/sync-between-azure-file-share-and-azure-blob-container/

So we have an Azure Automation Account, PowerShell runbook, and an existing docker image with azcopy in it.

This has been very helpful. One big snag is that for no reasons I can identify but I am able to verify, you can no longer specify a full command when creating a container instance, only an executable.

I'm building a complex azcopy command so I'm looking at uploading a script at the time of the container instance creation in my automation runbook.

I'm using New-AzContainerInstanceObject to create my instance and it has a -VolumeMount parameter which allows you to specify an instance of a Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.Api20210301.IVolumeMount[]
That can be created with the New-AzContainerInstanceVolumeMountObject command:
https://learn.microsoft.com/en-us/powershell/module/az.containerinstance/new-azcontainerinstancevolumemountobject?view=azps-6.3.0

Great, seem like I'm getting close. I know I could just modify the docker image I'm using but I'm pulling it directly from the repo and want to keep doing that.

Issue with the last command is that there is no example of how to use it and since I know I have to specify the RG, storage account as well as a SAS, the simple parameters asked for are not going to do it.

I did find this:
https://learn.microsoft.com/en-us/azure/container-instances/container-instances-volume-azure-files

But it uses az cli which will not help me with a PowerShell runbook. Really wish that equivalents were kept in sync between cli and PS.

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
676 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,196 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Monalla-MSFT 12,846 Reputation points
    2021-09-07T15:38:08.597+00:00

    @Amerman, Richard - Thanks for reaching out and for being patient while the PG is looking into this.

    Rephrasing what dingmeng has provided in the Github issue for larger audience.

    According to error message you were getting, the cmdlet cannot execute in docker container correctly. Below are few suggestions based on the script you are running :

    • You can simply your command and check whether container can execute command as expected or not. such as just touch one file. Or you can try command what you are using in local docker container.
    • Check the first HTTP request during New-AzContainerGroup. The payload of HTTP request contains what parameter is sent to ContainerInstance service.

    If you have already tried the above scenarios,

    Current repo of Azure PowerShell just takes the responsibility of client behavior and we ensure the request is sent to service correctly. But we have limited know in each service especially edge cases.

    To follow up on your question, you can select one of below approaches.

    • In order for us to troubleshoot further, We would like to put you in touch with a support engineer so you can receive 1:1 support for a deeper investigation on this. We would need you to send us an email at AzCommunity@Microsoft.com by providing below details.
      Subject : ATTN:Monika
      1. Subscription ID
      2. A link to this thread.
        Please email us these details and we will work with you closely to get this issue taken care of and also post any findings here in the thread so the community can
        benefit from it.
        Thanks in advance. Looking forward for your email.
    • You can leverage current GitHub issue too. But we need the payload of HTTP call and the last HTTP call during executing New-AzContainerGroup. Then, we will forward it to ContainerInstance team to look into it.

    Hope this helps.

    0 comments No comments