<p>we plan to use Azure Kubernetes Service for K8S. We have our Azure File Share.
Is it possible to reference somehow Azure File Share within the <strong>Pod or Deployment</strong> yaml definition so that volume can be mounted on the container (Pod) level? Is this reference something which needs to be defined during the AKS cluster creation or it is enough to reference it somehow when we execute <code>kubectl apply</code> command to deploy our containers Pods.</p>
<p>Thanks</p>

<p>So, as per <a href="https://learn.microsoft.com/en-us/azure/aks/azure-files-volume#mount-the-file-share-as-a-volume" rel="nofollow noreferrer">Mount the file share as a volume</a> documentation, provided by @AndreyDonald, you can reference like this</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - image: mcr.microsoft.com/oss/nginx/nginx:1.15.5-alpine
    name: mypod
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 250m
        memory: 256Mi
    volumeMounts:
      - name: azure
        mountPath: /mnt/azure
  volumes:
  - name: azure
    azureFile:
      secretName: azure-secret
      shareName: aksshare
      readOnly: false
</code></pre>
<p>But prior to that you should <a href="https://learn.microsoft.com/en-us/azure/aks/azure-files-volume#create-a-kubernetes-secret" rel="nofollow noreferrer">Create a Kubernetes secret</a>.</p>
<pre><code>kubectl create secret generic azure-secret --from-literal=azurestorageaccountname=$AKS_PERS_STORAGE_ACCOUNT_NAME --from-literal=azurestorageaccountkey=$STORAGE_KEY
</code></pre>
<p>And in order to create that secret you should use assign correct values to vars</p>
<pre><code>$AKS_PERS_STORAGE_ACCOUNT_NAME
$STORAGE_KEY
</code></pre>
<p>You dont have to create new File Share, just</p>
<pre><code># Get storage account key
STORAGE_KEY=$(az storage account keys list --resource-group $AKS_PERS_RESOURCE_GROUP --account-name $AKS_PERS_STORAGE_ACCOUNT_NAME --query &quot;[0].value&quot; -o tsv)
</code></pre>
<p>and use it.</p>
