azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

[Container Instances] Missing Example

Open ddobric opened this issue 3 years ago • 9 comments

I would like to mount the volume to the azure file storage. To do this I obviously need to use WithVolumeMountSetting. But the question is how?!

Want to do following with the C# Microsoft.Azure.Management.ContainerInstance.Fluent;:

   --azure-file-volume-account-name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --azure-file-volume-account-key $STORAGE_KEY \
    --azure-file-volume-share-name $ACI_PERS_SHARE_NAME \
    --azure-file-volume-mount-path /aci/logs/

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ddobric avatar Feb 28 '21 17:02 ddobric

Thank you for your feedback. Tagging and routing to the team member best able to assist.

jsquire avatar Mar 01 '21 14:03 jsquire

@ddobric Could you please provide the API version and VS version you're using? Thank you.

nisha-bhatia avatar Mar 03 '21 01:03 nisha-bhatia

Hi, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost avatar Mar 10 '21 02:03 ghost

This is the version of the fluent API that I use:

<PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.37.0" />

ddobric avatar Mar 17 '21 06:03 ddobric

Re-routing to the service team.

JonathanCrd avatar Mar 19 '21 18:03 JonathanCrd

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dkkapur.

Issue Details

I would like to mount the volume to the azure file storage. To do this I obviously need to use WithVolumeMountSetting. But the question is how?!

Want to do following with the C# Microsoft.Azure.Management.ContainerInstance.Fluent;:

   --azure-file-volume-account-name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --azure-file-volume-account-key $STORAGE_KEY \
    --azure-file-volume-share-name $ACI_PERS_SHARE_NAME \
    --azure-file-volume-mount-path /aci/logs/

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Author: ddobric
Assignees: -
Labels:

.NET Fluent SDK, Container Instances, Mgmt, Service Attention, customer-reported, needs-team-attention, question

Milestone: -

ghost avatar Mar 19 '21 18:03 ghost

@dkkapur Following up to see if there is any update on this issue? - Thank you

KranthiPakala-MSFT avatar Nov 01 '21 23:11 KranthiPakala-MSFT

Anything new? I would recommend providing in the API a generic approach to all other properties that might be used in the future. With this developers can use them even if the API does not support them explicitelly.

ddobric avatar Nov 17 '21 22:11 ddobric

Hi @ddobric , the fluent sdk is being deprecated, and the new sdk for Container Instance is here https://www.nuget.org/packages/Azure.ResourceManager.ContainerInstance/. @HarveyLink please help to provide a sample / test for this scenario.

ArthurMa1978 avatar Jan 10 '23 05:01 ArthurMa1978

Hi, @ddobric

As Microsoft.Azure.Management.Fluent has been deprecated, we recommend customers migrate to Azure.ResourceManager.XX Here is an example for creating an azure container with a volume, I hope it helps

environment

  • .net 6.0
  • Azure.ResourceManager.ContainerInstance 1.0.1

prerequisites

created a storage account that has a file share

// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
ArmClient client = new ArmClient(cred);
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier("subscriptionId", "resourceGroupName");
ResourceGroupResource resourceGroup = client.GetResourceGroupResource(resourceGroupResourceId);

string volumeName = "volume0";
string volumePath = $"/mnt/{volumeName}";
string sharedName = "<Your-File-Share>";
string storageAccountName = "<Storage-Account-Name>";
string storageAccountKey = "<Storage-Account-Key>";

// create a container with a volume
ContainerResourceRequirements requirements = new ContainerResourceRequirements(new ContainerResourceRequestsContent(memoryInGB: 1.5, cpu: 1));
var containers = new List<ContainerInstanceContainer>()
{
    new ContainerInstanceContainer("Container0", "mcr.microsoft.com/azuredocs/aci-helloworld:latest", requirements)
    {
        VolumeMounts =
        {
            new ContainerVolumeMount(volumeName, volumePath)
        },
    },
};
ContainerGroupData data = new ContainerGroupData(resourceGroup.Data.Location, containers, ContainerInstanceOperatingSystemType.Linux)
{
    Volumes =
    {
        new ContainerVolume(volumeName)
        {
            AzureFile = new ContainerInstanceAzureFileVolume(sharedName, storageAccountName)
            {
               StorageAccountKey = storageAccountKey,
            }
        },
    }
};
var containerGroup = await resourceGroup.GetContainerGroups().CreateOrUpdateAsync(WaitUntil.Completed, "containergroup0", data);
Console.WriteLine(containerGroup.Value.Data.Containers[0].VolumeMounts);
Console.WriteLine(containerGroup.Value.Data.Containers[0].VolumeMounts.Count);

dvbb avatar Feb 20 '23 08:02 dvbb

Hi, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost avatar Feb 27 '23 14:02 ghost