azure-sdk-for-net
azure-sdk-for-net copied to clipboard
[Container Instances] Missing Example
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.
- ID: c84fc88b-45dd-35d3-ee62-40e2df946b3e
- Version Independent ID: 268618d6-1521-7f40-4aa6-fdcd57d24050
- Content: IWithVolumeMountSetting<ParentT>.WithVolumeMountSetting Method (Microsoft.Azure.Management.ContainerInstance.Fluent.ContainerGroup.Definition) - Azure for .NET Developers
- Content Source: [xml/Microsoft.Azure.Management.ContainerInstance.Fluent.ContainerGroup.Definition/IWithVolumeMountSetting
1.xml](https://github.com/Azure/azure-docs-sdk-dotnet/blob/master/xml/Microsoft.Azure.Management.ContainerInstance.Fluent.ContainerGroup.Definition/IWithVolumeMountSetting
1.xml) - Service: container-instances
- GitHub Login: @CamSoper
- Microsoft Alias: casoper
Thank you for your feedback. Tagging and routing to the team member best able to assist.
@ddobric Could you please provide the API version and VS version you're using? Thank you.
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!
This is the version of the fluent API that I use:
<PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.37.0" />
Re-routing to the service team.
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.
- ID: c84fc88b-45dd-35d3-ee62-40e2df946b3e
- Version Independent ID: 268618d6-1521-7f40-4aa6-fdcd57d24050
- Content: IWithVolumeMountSetting<ParentT>.WithVolumeMountSetting Method (Microsoft.Azure.Management.ContainerInstance.Fluent.ContainerGroup.Definition) - Azure for .NET Developers
- Content Source: [xml/Microsoft.Azure.Management.ContainerInstance.Fluent.ContainerGroup.Definition/IWithVolumeMountSetting
1.xml](https://github.com/Azure/azure-docs-sdk-dotnet/blob/master/xml/Microsoft.Azure.Management.ContainerInstance.Fluent.ContainerGroup.Definition/IWithVolumeMountSetting
1.xml) - Service: container-instances
- GitHub Login: @CamSoper
- Microsoft Alias: casoper
Author: | ddobric |
---|---|
Assignees: | - |
Labels: |
|
Milestone: | - |
@dkkapur Following up to see if there is any update on this issue? - Thank you
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.
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.
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);
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!