الاحتفاظ بالملفات في Azure Cloud Shell
في المرة الأولى التي تبدأ فيها تشغيل Cloud Shell، تتم مطالبتك بتحديد خيارات التخزين الخاصة بك. إذا كنت تريد تخزين الملفات التي يمكن استخدامها في كل مرة تستخدم فيها Cloud Shell، فيجب عليك إنشاء موارد تخزين جديدة أو اختيار موارد تخزين موجودة. يستخدم Cloud Shell مشاركة ملفات Microsoft Azure لاستمرار الملفات عبر جلسات العمل.
- لإنشاء موارد تخزين جديدة، راجع بدء استخدام Azure Cloud Shell باستخدام التخزين المستمر.
- لاستخدام موارد التخزين الموجودة، راجع بدء استخدام Azure Cloud Shell باستخدام التخزين الحالي.
كيفية عمل موقع تخزين Cloud Shell
يحتفظ Cloud Shell بالملفات من خلال كلا الأسلوبين التاليين:
- إنشاء صورة قرص لاحتواء محتويات الدليل الخاص بك
$HOME
. يتم حفظ صورة القرص فيhttps://storageaccountname.file.core.windows.net/filesharename/.cloudconsole/acc_user.img
. يقوم Cloud Shell تلقائيا بمزامنة التغييرات على صورة القرص هذه. - تحميل مشاركة الملف كما هو الحال
clouddrive
في الدليل الخاص بك$HOME
./home/<User>/clouddrive
يتم تعيين المسار إلىstorageaccountname.file.core.windows.net/filesharename
.
إشعار
يتم الاحتفاظ بجميع الملفات الموجودة في $HOME
الدليل، مثل مفاتيح SSH، في صورة قرص المستخدم، المخزنة في مشاركة الملفات المثبتة. استخدم أفضل الممارسات لتأمين المعلومات في $HOME
الدليل ومشاركة الملفات المحملة.
تأمين الوصول إلى موقع التخزين
للأمان، يجب على كل مستخدم إنشاء حساب تخزين خاص به. بالنسبة إلى التحكم في الوصول المستند إلى الدور في Azure (RBAC)، يجب أن يكون لدى المستخدمين حق وصول المساهم أو أعلى على مستوى حساب التخزين.
يستخدم Cloud Shell مشاركة ملف Azure في حساب تخزين، داخل اشتراك محدد. نظرا للأذونات الموروثة، يمكن للمستخدمين الذين لديهم حقوق وصول كافية في الاشتراك الوصول إلى حسابات التخزين ومشاركات الملفات المضمنة في الاشتراك.
يجب على المستخدمين تأمين الوصول إلى ملفاتهم عن طريق تعيين الأذونات على حساب التخزين أو على مستوى الاشتراك.
يحتوي حساب تخزين Cloud Shell على ملفات أنشأها مستخدم Cloud Shell في دليله الرئيسي، والتي قد تتضمن معلومات حساسة بما في ذلك رموز الوصول المميزة أو بيانات الاعتماد.
تقييد إنشاء الموارد باستخدام نهج موارد Azure
يتم وضع علامة على حسابات التخزين التي تم إنشاؤها في Cloud Shell باستخدام ms-resource-usage:azure-cloud-shell
.
إذا كنت ترغب في عدم السماح للمستخدمين بإنشاء حسابات تخزين في Cloud Shell، قم بإنشاء نهج مورد Azure الذي يتم تشغيله بواسطة هذه العلامة المحددة.
إدارة تخزين Cloud Shell
استخدام الأمرclouddrive
يتضمن Cloud Shell أداة سطر الأوامر التي تمكنك من تغيير مشاركة ملفات Azure الموجودة في Cloud Shell. قم بتشغيل clouddrive
لمشاهدة الأوامر المتوفرة.
Group
clouddrive :Manage storage settings for Azure Cloud Shell.
Commands
mount :Mount a file share to Cloud Shell.
unmount :Unmount a file share from Cloud Shell.
إدخال clouddrive جديد
clouddrive mount
استخدم الأمر لتغيير المشاركة المستخدمة من قبل Cloud Shell.
إشعار
إذا كنت تقوم بتحميل مشاركة جديدة، يتم إنشاء صورة مستخدم جديدة للدليل الخاص بك $HOME
. يتم الاحتفاظ بالصورة السابقة $HOME
في مشاركة الملف السابق.
شغّل الأمر clouddrive mount
مع المعلمات التالية:
clouddrive mount -s mySubscription -g myRG -n storageAccountName -f fileShareName
لمزيد من المعلومات، قم بتشغيل clouddrive mount -h
.
Command
clouddrive mount :Mount an Azure file share to Cloud Shell.
Mount enables mounting and associating an Azure file share to Cloud Shell.
Cloud Shell will automatically attach this file share on each session start-up.
Note: This command does not mount storage if the session is Ephemeral.
Cloud Shell persists files with both methods below:
1. Create a disk image of your $HOME directory to persist files within $HOME.
This disk image is saved in your specified file share as 'acc_sean.img'' at
'//<storageaccount>.file.storage.windows.net/<fileshare>/.cloudconsole/acc_sean.img'
2. Mount specified file share as 'clouddrive' in $HOME for file sharing.
'/home/sean/clouddrive' maps to '//<storageaccount>.file.storage.windows.net/<fileshare>'
Arguments
-s | --subscription id [Required]:Subscription ID or name.
-g | --resource-group group [Required]:Resource group name.
-n | --storage-account name [Required]:Storage account name.
-f | --file-share name [Required]:File share name.
-d | --disk-size size :Disk size in GB. (default 5)
-F | --force :Skip warning prompts.
-? | -h | --help :Shows this usage text.
إلغاء إدخال المحرك السحابي
يمكنك إلغاء تحميل مشاركة ملف Cloud Shell في أي وقت. نظرا لأن Cloud Shell يتطلب استخدام مشاركة ملف مثبتة، يطالبك Cloud Shell بإنشاء مشاركة ملف أخرى وتثبيتها في جلسة العمل التالية.
- شغّل
clouddrive unmount
. - عليك الإقرار بالمطالبات وتأكيدها.
تستمر مشاركة الملف غير الملغى في الوجود حتى تقوم بحذفها يدويا. بعد إلغاء التحميل، لم يعد Cloud Shell يبحث عن مشاركة الملف هذه في جلسات العمل اللاحقة. لمزيد من المعلومات، قم بتشغيل clouddrive unmount -h
،
Command
clouddrive unmount: Unmount an Azure file share from Cloud Shell.
Unmount enables unmounting and disassociating a file share from Cloud Shell.
All current sessions will be terminated. Machine state and non-persisted files will be lost.
You will be prompted to create and mount a new file share on your next session.
Your previously mounted file share will continue to exist.
Note: This command does not unmount storage if the session is Ephemeral.
Arguments
None
تحذير
على الرغم من أن تشغيل هذا الأمر لا يحذف أي موارد، إلا أن حذف مجموعة موارد أو حساب تخزين أو مشاركة ملف تم تعيينه إلى Cloud Shell يدويا يؤدي إلى مسح $HOME
صورة قرص الدليل وأي ملفات في مشاركة الملف. لا يمكن التراجع عن هذا الإجراء.
استخدام أوامر PowerShell
الحصول على معلومات حول مشاركة الملف الحالي
Get-CloudDrive
استخدم الأمر في PowerShell للحصول على معلومات حول الموارد التي تدعم مشاركة الملف.
PS /home/user> Get-CloudDrive
FileShareName : cs-user-microsoft-com-xxxxxxxxxxxxxxx
FileSharePath : //cs7xxxxxxxxxxxxxxx.file.core.windows.net/cs-user-microsoft-com-xxxxxxxxxxxxxxx
MountPoint : /home/user/clouddrive
Name : cs7xxxxxxxxxxxxxxx
ResourceGroupName : cloud-shell-storage-southcentralus
StorageAccountName : cs7xxxxxxxxxxxxxxx
SubscriptionId : 78a66d97-7204-4a0d-903f-43d3d4170e5b
إلغاء تحميل مشاركة الملف
يمكنك إلغاء تحميل مشاركة ملف Cloud Shell في أي وقت باستخدام Dismount-CloudDrive
cmdlet.
يؤدي إلغاء تحميل clouddrive
إلى إنهاء جلسة العمل الحالية.
Dismount-CloudDrive
Do you want to continue
Dismounting clouddrive will terminate your current session. You will be prompted to create and
mount a new file share on your next session
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):