使用 Azure 儲存體總管處理資料Work with data using Azure Storage Explorer

在 Azure 儲存體總管中使用 Azure Cosmos DB 可讓使用者管理 Azure Cosmos DB 實體、操縱資料、更新預存程序及觸發程序,以及其他 Azure 實體 (例如儲存體 Blob 及佇列)。Using Azure Cosmos DB in Azure Storage Explorer enables users to manage Azure Cosmos DB entities, manipulate data, update stored procedures and triggers along with other Azure entities like Storage blobs and queues. 現在您可以使用同一個工具在同一處管理您不同的 Azure 實體。Now you can use the same tool to manage your different Azure entities in one place. 目前,Azure 儲存體總管支援對 SQL、MongoDB、Graph 和資料表 API 設定 Cosmos 帳戶。At this time, Azure Storage Explorer supports Cosmos accounts configured for SQL, MongoDB, Graph, and Table APIs.

先決條件Prerequisites

Cosmos 帳戶,需具有 SQL API 或適用於 MongoDB 的 Azure Cosmos DB API。A Cosmos account with SQL API or Azure Cosmos DB's API for MongoDB. 若您還沒有帳戶,您可以根據 Azure Cosmos DB:使用 .NET 及 Azure 入口網站建置 SQL API Web 應用程式中的說明,在 Azure 入口網站中建立帳戶。If you don't have an account, you can create one in the Azure portal, as described in Azure Cosmos DB: Build a SQL API web app with .NET and the Azure portal.

安裝Installation

在此處安裝最新版本的 Azure 儲存體總管:Azure 儲存體總管,我們現在支援 Windows、Linux 及 MAC 版本。Install the newest Azure Storage Explorer bits here: Azure Storage Explorer, now we support Windows, Linux, and MAC version.

連線到 Azure 訂用帳戶Connect to an Azure subscription

  1. 在安裝 Azure 儲存體總管之後,按一下左邊的外掛程式圖示,如下圖所示:After installing the Azure Storage Explorer, click the plug-in icon on the left as shown in the following image:

    外掛程式圖示

  2. 選取 [新增 Azure 帳戶] ,然後按一下 [登入] 。Select Add an Azure Account, and then click Sign-in.

    連線到 Azure 訂用帳戶

  3. 在 [Azure 登入] 對話方塊中,選取 [登入] ,然後輸入您的 Azure 認證。In the Azure Sign in dialog box, select Sign in, and then enter your Azure credentials.

    登入

  4. 從清單中選取您的訂用帳戶,然後按一下 [套用] 。Select your subscription from the list and then click Apply.

    套用

    [總管] 窗格會更新,並顯示選取之訂閱中的帳戶。The Explorer pane updates and displays the accounts in the selected subscription.

    帳戶清單

    您已成功將您的 Cosmos DB 帳戶連線到您的 Azure 訂用帳戶。You have successfully connected to your Cosmos DB account to your Azure subscription.

使用連接字串連線到 Azure Cosmos DBConnect to Azure Cosmos DB by using a connection string

另外一種連線到 Azure Cosmos DB 的方式為使用連接字串。An alternative way of connecting to an Azure Cosmos DB is to use a connection string. 使用下列步驟來使用連接字串進行連線。Use the following steps to connect using a connection string.

  1. 在左邊的樹狀目錄中尋找 [Local and Attached] (本機與已連結) ,以滑鼠右鍵按一下 [Cosmos DB 帳戶] ,選擇 [連線到 Cosmos DB...] Find Local and Attached in the left tree, right-click Cosmos DB Accounts, choose Connect to Cosmos DB...

    透過連接字串連線到 Cosmos DB

  2. 目前僅支援 SQL 和資料表 API。Only support SQL and Table API currently. 選擇 API、貼上連接字串、輸入帳戶標籤、按 [下一步] 以檢查摘要,然後按一下 [連線] 以連線到 Azure Cosmos DB 帳戶。Choose API, paste Connection String, input Account label, click Next to check the summary, and then click Connect to connect Azure Cosmos DB account. 如需擷取連接字串的資訊,請參閱取得連接字串For information on retrieving the connection string, see Get the connection string.

    連接字串

使用本機模擬器連線到 Azure Cosmos DBConnect to Azure Cosmos DB by using local emulator

若要使用模擬器連線到 Azure Cosmos DB,請使用下列步驟 (目前僅支援 SQL 帳戶)。Use the following steps to connect to an Azure Cosmos DB by Emulator, only support SQL account currently.

  1. 安裝模擬器並啟動。Install Emulator and launch. 如需了解如何安裝模擬器,請參閱 Cosmos DB 模擬器For how to install Emulator, see Cosmos DB Emulator

  2. 在左邊的樹狀目錄中尋找 [Local and Attached] (本機與已連結) ,以滑鼠右鍵按一下 [Cosmos DB 帳戶] ,選擇 [連線到 Cosmos DB 模擬器...] Find Local and Attached in the left tree, right-click Cosmos DB Accounts, choose Connect to Cosmos DB Emulator...

    使用模擬器連線到 Cosmos DB

  3. 目前僅支援 SQL API。Only support SQL API currently. 貼上連接字串、輸入帳戶標籤、按 [下一步] 以檢查摘要,然後按一下 [連線] 以連線到 Azure Cosmos DB 帳戶。Paste Connection String, input Account label, click Next to check the summary, and then click Connect to connect Azure Cosmos DB account. 如需擷取連接字串的資訊,請參閱取得連接字串For information on retrieving the connection string, see Get the connection string.

    使用模擬器對話方塊連線到 Cosmos DB

Azure Cosmos DB 資源管理Azure Cosmos DB resource management

您可以透過執行下列作業來管理 Azure Cosmos DB 帳戶:You can manage an Azure Cosmos DB account by doing following operations:

  • 在 Azure 入口網站中開啟帳戶Open the account in the Azure portal
  • 將資源新增至快速存取清單Add the resource to the Quick Access list
  • 搜尋和重新整理資源Search and refresh resources
  • 建立和刪除資料庫Create and delete databases
  • 建立和刪除集合Create and delete collections
  • 建立、編輯、刪除和篩選文件Create, edit, delete, and filter documents
  • 管理預存程序、觸發程序和使用者定義函式Manage stored procedures, triggers, and user-defined functions

快速存取工作Quick access tasks

以滑鼠右鍵按一下 [總管] 窗格中的訂用帳戶,您可以執行許多快速動作工作:By right-clicking on a subscription in the Explorer pane, you can perform many quick action tasks:

  • 以滑鼠右鍵按一下 Azure Cosmos DB 帳戶或資料庫,您可以選擇 [在入口網站中開啟] 並使用瀏覽器在 Azure 入口網站上管理資源。Right-click an Azure Cosmos DB account or a database, you can choose Open in Portal and manage the resource in the browser on the Azure portal.

    在入口網站中開啟

  • 您也可以將 Azure Cosmos DB 帳戶、資料庫及集合新增至 [快速存取] 。You can also add Azure Cosmos DB account, database, collection to Quick Access.

  • [Search from Here] (從這裡搜尋) 可在選取的路徑下使用關鍵字搜尋。Search from Here enables keyword search under the selected path.

    從這裡搜尋

資料庫與集合管理Database and collection management

建立資料庫Create a database

  • 以滑鼠右鍵按一下 Azure Cosmos DB 帳戶,選擇 [建立資料庫] ,輸入資料庫名稱,然後按 ENTER 鍵以完成。Right-click the Azure Cosmos DB account, choose Create Database, input the database name, and press Enter to complete.

    建立資料庫

刪除資料庫Delete a database

  • 以滑鼠右鍵按一下資料庫,按一下 [刪除資料庫] ,然後在快顯視窗中按一下 [是] 。Right-click the database, click Delete Database, and click Yes in the pop-up window. 資料庫節點隨即會刪除,而 Azure Cosmos DB 帳戶會自動重新整理。The database node is deleted, and the Azure Cosmos DB account refreshes automatically.

    刪除 database1

    刪除 database2

建立集合Create a collection

  1. 以滑鼠右鍵按一下您的資料庫,選擇 [建立集合] ,然後提供下列資訊 (例如集合識別碼儲存體容量等)。 按一下 [確定] 以完成。Right-click your database, choose Create Collection, and then provide the following information like Collection ID, Storage capacity, etc. Click OK to finish.

    建立 collection1

    建立 collection2

  2. 選取 [無限制] 即可指定分割區索引鍵,然後按一下 [確定] 以完成。Select Unlimited to be able to specify partition key, then click OK to finish.

    若在建立集合時使用了分割區索引鍵,則一旦建立過程完成後,該分割區索引鍵的值便不能在集合上進行變更。If a partition key is used when creating a collection, once creation is completed, the partition key value can't be changed on the collection.

    資料分割索引鍵

刪除集合Delete a collection

  • 以滑鼠右鍵按一下集合,按一下 [刪除集合] ,然後在快顯視窗中按一下 [是] 。Right-click the collection, click Delete Collection, and then click Yes in the pop-up window.

    集合節點隨即刪除,且資料庫會自動重新整理。The collection node is deleted, and the database refreshes automatically.

    刪除集合

文件管理Document management

建立及修改文件Create and modify documents

  • 若要建立新文件,請在左邊視窗中開啟 [文件] ,按一下 [新增文件] ,在右邊窗格中編輯內容,然後按一下 [儲存] 。To create a new document, open Documents in the left window, click New Document, edit the contents in the right pane, then click Save. 您可以也更新現有的文件,然後按一下 [儲存] 。You can also update an existing document, and then click Save. 按一下 [捨棄] 以捨棄變更。Changes can be discarded by clicking Discard.

    文件

刪除文件Delete a document

  • 按一下 [刪除] 按鈕來刪除選取的文件。Click the Delete button to delete the selected document.

查詢文件Query for documents

  • 輸入 SQL 查詢,然後按一下 [套用] 來編輯文件篩選。Edit the document filter by entering a SQL query and then click Apply.

    文件篩選器

圖表管理Graph management

建立及修改頂點Create and modify vertex

  1. 若要建立新的頂點,請從左側視窗中開啟 [圖表] ,按一下 [新增頂點] 並編輯內容,然後按一下 [確定] 。To create a new vertex, open Graph from the left window, click New Vertex, edit the contents, then click OK.

  2. 若要修改現有的頂點,按一下右側窗格中的畫筆圖示。To modify an existing vertex, click the pen icon in the right pane.

    圖形

建立圖表Delete a graph

  • 若要刪除頂點,按一下頂點名稱旁的 [資源回收筒] 圖示。To delete a vertex, click the recycle bin icon beside the vertex name.

篩選圖表Filter for graph

  • 輸入 Gremlin 查詢 來編輯圖表篩選器,然後按一下 [套用篩選條件] 。Edit the graph filter by entering a gremlin query and then click Apply Filter.

    圖表篩選器

資料表管理Table management

建立及修改資料表Create and modify table

  1. 若要建立新的資料表,請從左側視窗開啟 [實體] ,按一下 [新增] 、編輯 [新增實體] 對話方塊中的內容、按一下 [新增屬性] 按鈕來新增屬性,然後按一下 [插入] 。To create a new table, open Entities from the left window, click Add, edit the content in Add Entity dialog, add property by clicking button Add Property, then click Insert.

  2. 若要修改資料表,請按一下 [編輯] 並修改內容,然後按一下 [更新] 。To modify a table, click Edit, modify the content, then click Update.

    資料表

匯入和匯出資料表Import and export table

  1. 若要匯入,請按一下 [匯入] 按鈕,並選擇現有的資料表。To import, click Import button and choose an existing table.

  2. 若要匯出,請按一下 [匯出] 按鈕,並選擇目的地。To export, click Export button and choose a destination.

    資料表匯入和匯出

刪除實體Delete entities

  • 選取實體,然後按一下 [刪除] 按鈕。Select the entities and click button Delete.

    資料表刪除

查詢資料表Query table

  • 按一下 [查詢] 按鈕、輸入查詢條件,然後按一下 [執行查詢] 按鈕。Click Query button, input query condition, then click Execute Query button. 按一下 [關閉查詢] 按鈕即可關閉 [查詢] 窗格。Close Query pane by clicking Close Query button.

    資料表查詢

管理預存程序、觸發程序和 UDFManage stored procedures, triggers, and UDFs

  • 若要建立預存程序,請在左邊的樹狀目錄中,以滑鼠右鍵按一下 [預存程序] ,選擇 [建立預存程序] ,在左邊輸入名稱,在右邊的視窗中輸入預存程序指令碼,然後按一下 [建立] 。To create a stored procedure, in the left tree, right-click Stored Procedure, choose Create Stored Procedure, enter a name in the left, type the stored procedure scripts in the right window, and then click Create.

  • 您也可以透過按兩下現有的預存程序,進行更新,然後按一下 [更新] 以儲存,或按一下 [捨棄] 以取消變更,來編輯現有的預存程序。You can also edit existing stored procedures by double-clicking, making the update, and then clicking Update to save, or click Discard to cancel the change.

    預存程序

  • 觸發程序UDF 的作業與預存程序雷同。The operations for Triggers and UDF are similar with Stored Procedures.

疑難排解Troubleshooting

Azure 儲存體總管中的 Azure Cosmos DB 是獨立應用程式,可讓您從 Windows、macOS 或 Linux 連線到裝載在 Azure 和主權雲端上的 Azure Cosmos DB 帳戶。Azure Cosmos DB in Azure Storage Explorer is a standalone app that allows you to connect to Azure Cosmos DB accounts hosted on Azure and Sovereign Clouds from Windows, macOS, or Linux. 也可讓您管理 Azure Cosmos DB 實體、操縱資料、更新預存程序及觸發程序,以及其他 Azure 實體 (例如儲存體 Blob 及佇列)。It enables you to manage Azure Cosmos DB entities, manipulate data, update stored procedures and triggers along with other Azure entities like Storage blobs and queues.

這些是儲存體總管中有關 Azure Cosmos DB 常見問題的解決方案。These are solutions for common issues seen for Azure Cosmos DB in Storage Explorer.

登入問題Sign in issues

在繼續之前,請先嘗試重新啟動您的應用程式,查看是否能修正問題。Before proceeding further, try restarting your application and see if the problems can be fixed.

信任鏈結中的自我簽署憑證Self-signed certificate in certificate chain

有幾個原因可能會導致此錯誤,最常見的兩個原因是:There are a few reasons you may be seeing this error, the two most common ones are:

  • 您在「透明 Proxy」 背後,這表示有人 (例如您的 IT 部門) 正使用自我簽署憑證攔截 HTTPS 流量、解密再加密。You're behind a transparent proxy, which means someone (such as your IT department) is intercepting HTTPS traffic, decrypting it, and then encrypting it using a self-signed certificate.

  • 您正在執行的軟體,例如防毒軟體,會將自我簽署的 SSL 憑證插入您收到的 HTTPS 訊息中。You're running software, such as anti-virus software, which is injecting a self-signed SSL certificates into the HTTPS messages you receive.

當儲存體總管遇到這些「自我簽署憑證」的其中一個時,它可能就無法知曉收到的 HTTPS 訊息是否已遭竄改。When Storage Explorer encounters one of these "self-signed certificates", it can no longer know if the HTTPS message it's receiving has been tampered with. 如果您有一份自我簽署憑證,則可以告知儲存體總管信任該憑證。If you have a copy of the self-signed certificate though, then you can tell Storage Explorer to trust it. 如果您不確定插入憑證的是誰,可以嘗試執行下列步驟來自行尋找:If you're unsure of who is injecting the certificate, then you can try to find it yourself by doing the following steps:

  1. 安裝 Open SSLInstall Open SSL
    • Windows (任一輕裝版即可)Windows (any of the light versions is ok)
    • Mac 及 Linux:應該包含在作業系統中Mac and Linux: Should be included with your operating system
  2. 執行 Open SSLRun Open SSL
    • Windows:移至安裝目錄並找到 /bin/ ,然後按兩下 openssl.exeWindows: Go to the install directory, then /bin/, then double-click on openssl.exe.
    • Mac 和 Linux:從終端機執行 opensslMac and Linux: execute openssl from a terminal
  3. 執行 s_client -showcerts -connect microsoft.com:443Execute s_client -showcerts -connect microsoft.com:443
  4. 尋找自我簽署憑證。Look for self-signed certificates. 如果不確定哪些是自我簽署的憑證,請尋找主旨 ("s:") 和簽發者 ("i:") 相同的所有位置。If you're unsure, which are self-signed, then look for anywhere the subject ("s:") and issuer ("i:") are the same.
  5. 一旦發現任何自我簽署的憑證,請針對每個憑證,將從 -----BEGIN CERTIFICATE----------END CERTIFICATE----- (含) 的所有內容,複製並貼到新的 .cer 檔案。Once you have found any self-signed certificates, copy and paste everything from and including -----BEGIN CERTIFICATE----- to -----END CERTIFICATE----- to a new .cer file for each one.
  6. 開啟儲存體總管,然後移至 [編輯] > [SSL 憑證] > [匯入憑證] 。Open Storage Explorer and then go to Edit > SSL Certificates > Import Certificates. 使用檔案選擇器來尋找、選取及開啟您所建立的 .cer 檔案。Using the file picker, find, select, and open the .cer files you created.

如果使用上述步驟找不到任何自我簽署的憑證,請傳送意見反應給我們,以取得更多協助。If you're unable to find any self-signed certificates using the above steps, could send feedback for more help.

無法擷取訂用帳戶Unable to retrieve subscriptions

如果您成功登入之後,卻無法擷取訂用帳戶:If you're unable to retrieve your subscriptions after you successfully signed in:

  • 透過登入 Azure 入口網站確認您的帳戶可存取訂用帳戶的項目Verify your account has access to the subscriptions by signing into the Azure Portal
  • 確定已使用正確的環境登入 (AzureAzure 中國Azure 德國Azure 美國政府或自訂環境/Azure Stack)Make sure you have signed in using the correct environment (Azure, Azure China, Azure Germany, Azure US Government, or Custom Environment/Azure Stack)
  • 如果您是在 Proxy 背景,請確定已正確設定儲存體總管的 ProxyIf you're behind a proxy, make sure that you have configured the Storage Explorer proxy properly
  • 嘗試移除再重新新增帳戶Try removing and readding the account
  • 嘗試從主目錄刪除下列檔案 (例如:C:\Users\ContosoUser),再重新新增帳戶:Try deleting the following files from your home directory (such as: C:\Users\ContosoUser), and then readding the account:
    • .adalcache.adalcache
    • .devaccounts.devaccounts
    • .extaccounts.extaccounts
  • 登入時若出現任何錯誤訊息,請查看開發人員工具主控台 (f12)Watch the developer tools console (f12) while signing in for any error messages

console

看不到驗證頁面Unable to see the authentication page

如果您看不到驗證頁面:If you're unable to see the authentication page:

  • 載入登入頁面可能需要一些時間,視連線速度而定,請等待至少一分鐘再關閉 [驗證] 對話方塊Depending on the speed of your connection, it may take a while for the sign-in page to load, wait at least one minute before closing the authentication dialog
  • 如果您是在 Proxy 背景,請確定已正確設定儲存體總管的 ProxyIf you're behind a proxy, make sure that you have configured the Storage Explorer proxy properly
  • 按下 F12 鍵,開發人員主控台會隨即顯示。Bring up the developer console by pressing F12 key. 查看開發人員主控台的回應,看看能否找到任何驗證無法運作的線索Watch the responses from developer console and see if you can find any clue for why authentication is not working

無法移除帳戶Cannot remove account

如果無法移除帳戶,或重新驗證連結不執行任何動作If you're unable to remove an account, or if the reauthenticate link does not do anything

  • 嘗試從主目錄刪除下列檔案,再重新新增帳戶:Try deleting the following files from your home directory, and then readding the account:
    • .adalcache.adalcache
    • .devaccounts.devaccounts
    • .extaccounts.extaccounts
  • 如果您想要移除 SAS 連結的儲存體資源,請刪除:If you want to remove SAS attached Storage resources, delete:
    • Windows 是 %AppData%/StorageExplorer 資料夾%AppData%/StorageExplorer folder for Windows
    • Mac 是 /Users/<您的名稱>/Library/Applicaiton SUpport/StorageExplorer/Users/<your_name>/Library/Application SUpport/StorageExplorer for Mac
    • Linux 是 ~/.config/StorageExplorer~/.config/StorageExplorer for Linux
    • 如果刪除這些檔案,您必須重新輸入所有認證You will have to reenter all your credentials if you delete these files

Http/Https Proxy 的問題Http/Https proxy issue

在 ASE 中設定 Http/Https Proxy 時,無法在左側樹狀目錄中列出 Azure Cosmos DB 節點。You cannot list Azure Cosmos DB nodes in left tree when configuring http/https proxy in ASE. 這是已知問題,並將在下一個版本中修正。It's a known issue, and will be fixed in next release. 目前您可以使用 Azure 入口網站中的 Azure Cosmos DB 資料總管解決此問題。You could use Azure Cosmos DB data explorer in Azure portal as a work-around at this moment.

「本機與已連結」節點下的「開發」節點問題"Development" node under "Local and Attached" node issue

當您在左側樹狀目錄中,按一下 [本機及連結] 節點下的 [開發] 節點後,系統沒有回應。There is no response after clicking the "Development" node under "Local and Attached" node in left tree. 這是預期中的行為。The behavior is expected. 將在下一個版本中提供 Azure DB Cosmos 本機模擬器支援。Azure Cosmos DB local emulator will be supported in next release.

開發節點

在「本機與已連結」節點中連結 Azure Cosmos DB 帳戶的錯誤Attaching Azure Cosmos DB account in "Local and Attached" node error

如果您在「本機與已連結」節點中連結 Azure Cosmos DB 帳戶後看到以下錯誤,請檢查您是否使用正確的連接字串。If you see below error after attaching Azure Cosmos DB account in "Local and Attached" node, then check if you're using the right connection string.

在本機與已連結中連結 Azure Cosmos DB 的錯誤

展開 Azure Cosmos DB 節點錯誤Expand Azure Cosmos DB node error

當您嘗試展開左側的樹狀節點時,可能會看到下列錯誤。You may see below error while trying to expand the tree nodes in left.

展開錯誤

請嘗試下列建議:Try the following suggestions:

  • 檢查 Azure Cosmos DB 帳戶是否正在進行佈建,並在帳戶成功建立後再試一次。Check if the Azure Cosmos DB account is in provision progress and try again when the account is being created successfully.
  • 如果帳戶是在「快速存取」節點或「本機與已連結」節點下,請檢查帳戶是否已遭到刪除。If the account is under "Quick Access" node or "Local and Attached" nodes, then check if the account has been deleted. 如果是這樣,您需要以手動方式移除節點。If so, you need to remove the node manually.

與我們連絡Contact us

如果沒有適合您的解決方案,請將問題詳細資料以電子郵件傳送給 Azure Cosmos DB 開發工具小組 (cosmosdbtooling@microsoft.com),以修正問題。If none of the solutions work for you, send email to Azure Cosmos DB Dev Tooling Team (cosmosdbtooling@microsoft.com) with details about the issue, for fixing the issues.

後續步驟Next steps