博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
azure 免费帐户注册_如何使用模拟器模拟Azure SQL数据库存储帐户行为
阅读量:2513 次
发布时间:2019-05-11

本文共 8676 字,大约阅读时间需要 28 分钟。

azure 免费帐户注册

介绍 (Introduction)

When you practice and play with the Azure Storage, you spent money because you need to pay for the service. This obviously provides an incentive to discover a way to emulate the Azure Storage behavior.

在练习和使用Azure存储时,您花了钱,因为您需要为服务付费。 显然,这提供了一种动机来探索一种模仿Azure存储行为的方法。

In this article, we will use an emulator and learn how it works.

在本文中,我们将使用模拟器并学习其工作原理。

要求 (Requirements)

  1. First, we will need SQL Server installed

    首先,我们需要安装SQL Server
  2. Secondly, we will install SQL Server Management Studio (SSMS)

    其次,我们将安装SQL Server Management Studio(SSMS)
  3. Finally, you will need administrator privileges to install the software.

    最后,您将需要管理员权限才能安装软件。

入门 (Getting Started)

Working with the Azure Storage is cheap, but if you are just practicing, you will not want to spend money on it. Here you have the list of prices:

使用Azure存储很便宜,但是如果您只是在练习,就不要在上面花钱。 这里有价格表:

To avoid these costs, we will download the Azure Storage Emulator. You can download the emulator using the following link:

为避免这些费用,我们将下载Azure存储模拟器。 您可以使用以下链接下载仿真器:

It is also included with the Microsoft Azure SDKs.

它还包含在Microsoft Azure SDK中。

The installer is downloaded by default in the following path:

默认情况下,将通过以下路径下载安装程序:

:\Program Files (x86)\Microsoft SDKs\Azure

You will find the configuration file there (AzureStorageEmulator.exe.config):

您将在此处找到配置文件(AzureStorageEmulator.exe.config):

This emulator uses OData to access and connect to the information. The URLs used to access to the blobs, queue messages and tables are the following:

该仿真器使用OData访问并连接到信息。 以下是用于访问Blob,队列消息和表的URL:

  • Blobs: http://127.0.0.1:10000/

    Blob:http://127.0.0.1:10000 /
  • Queues: http://127.0.0.1:10001/

    队列:http://127.0.0.1:10001 /
  • Tables: http://127.0.0.1:10002/

    表格:http://127.0.0.1:10002 /

The account key used by the account name “devstoreaccount1” is in this configuration file and it is the following:

帐户名称“ devstoreaccount1”使用的帐户密钥在此配置文件中,并且如下所示:

Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==

If you need to simulate a proxy, you can add the following line in the configuration file:

如果需要模拟代理,则可以在配置文件中添加以下行:

UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://yourProxyUri

To create the database, you can run the following command in the folder where the emulator is installed:

要创建数据库,可以在安装模拟器的文件夹中运行以下命令:

AzureStorageEmulator.exe init

This command will create a database in the localdb. If you do not know what is the localDB and how to use it, we recommend reading our following article:

此命令将在localdb中创建一个数据库。 如果您不知道什么是localDB以及如何使用它,建议您阅读以下文章:

To start the Azure Storage emulator run the following command in the folder where it is installed:

若要启动Azure存储模拟器,请在其安装文件夹中运行以下命令:

AzureStorageEmulator.exe start

To stop your emulator, you can use the following command:

要停止模拟器,可以使用以下命令:

Storage Emulator>AzureStorageEmulator.exe stop

To show the status of the emulator you can run the following command:

要显示仿真器的状态,可以运行以下命令:

Storage Emulator>AzureStorageEmulator.exe status

If it is running the status will be the following: IsRunning: True

如果正在运行,则状态为以下: IsRunning:True

To clear all the blob data, use the following command:

要清除所有斑点数据,请使用以下命令:

AzureStorageEmulator.exe clear blob

You can also clear queue or table data using the following commands:

您还可以使用以下命令清除队列或表数据:

AzureStorageEmulator.exe clear queue

And

AzureStorageEmulator.exe clear table

Now, in the SSMS, connect to the database created:

现在,在SSMS中,连接到创建的数据库:

You can also verify the tables created by the Azure Storage Emulator:

您还可以验证由Azure存储模拟器创建的表:

To test and verify these tables, we will download the Microsoft Azure Storage Explorer (MASE). You can download the program here:

为了测试和验证这些表,我们将下载Microsoft Azure存储资源管理器(MASE)。 您可以在此处下载程序:

Install the MASE. MASE can help you to upload and download files to Azure or to the Azure emulator. You can also create Queues and tables.

安装MASE。 MASE可以帮助您将文件上传和下载到Azure或Azure仿真器。 您还可以创建队列和表。

We will upload some files and create some containers first.

我们将首先上传一些文件并创建一些容器。

If you have an Azure Account you will need to sign in with your Azure credentials, otherwise, you can omit that part.

如果您具有Azure帐户,则需要使用Azure凭据登录,否则,可以省略该部分。

In MASE, go to Local and Attached, expand it and to Storage Accounts, Development and Blob Containers:

在MASE中,转到“本地和附件”,展开它,再到“存储帐户,开发和Blob容器”:

In the Blob Container can right click and create new blob containers. We will create a blob container named container1. In the container1, you can create new folders upload and download files.

在Blob容器中,可以右键单击并创建新的Blob容器。 我们将创建一个名为container1的Blob容器。 在container1中,您可以创建新的文件夹来上传和下载文件。

You can verify your accounts in SQL Server. The following query will show the account information including secret keys, queue, blob and table settings:

您可以在SQL Server中验证您的帐户。 以下查询将显示帐户信息,包括密钥,队列,blob和表设置:

SELECT  [Name]      ,[SecretKey]      ,[QueueServiceSettings]      ,[BlobServiceSettings]      ,[TableServiceSettings]      ,[SecondaryKey]      ,[SecondaryReadEnabled]  FROM [AzureStorageEmulatorDb53].[dbo].[Account]

The table displayed is the following:

显示的表如下:

You can also check your Blob Container information. Using the BlobContainer table including the last modification date and lease information:

您还可以检查您的Blob容器信息。 使用包含上次修改日期和租约信息的BlobContainer表:

If you query the dbo.BlobContainer table, you will be able to see the container just created:

如果查询dbo.BlobContainer表,您将能够看到刚刚创建的容器:

Select * from dbo.BlogContainer

Other internal tables of the Azure Storage Emulator are the following:

Azure存储模拟器的其他内部表如下:

  • Dbo.CommittedBlock contains information about the Azure Account Name, Container name, BlobName and the blocks used. The Azure Storage Accounts.

    Dbo.CommittedBlock包含有关Azure帐户名称,容器名称,BlobName和使用的块的信息。 Azure存储帐户。
  • Dbo.CurrentPage will give you page information about the blobs.

    Dbo.CurrentPage将为您提供有关Blob的页面信息。
  • Dbo.DeletedAccount contains the accounts removed.

    Dbo.DeletedAccount包含已删除的帐户。
  • Dbo.Page handles page information about the blobs contained.

    Dbo.Page处理有关包含的Blob的页面信息。

We can also work with Queues in Azure. In MASE, go to Local and Attached, Storage Accounts, Development, Queues.

我们还可以在Azure中使用队列。 在MASE中,转到“本地和附加”,“存储帐户”,“开发”,“队列”。

Right click on Queues and create a new Queue named Queue1:

右键单击队列,然后创建一个名为Queue1的新队列:

In the Queue, press Add Message and write a message:

在队列中,按添加消息并编写一条消息:

The following query will show the information related to the Queue information:

以下查询将显示与队列信息有关的信息:

SELECT TOP  [AccountName]      ,[QueueName]      ,[LastModificationTime]      ,[ServiceMetadata]      ,[Metadata]  FROM [AzureStorageEmulatorDb53].[dbo].[QueueContainer]

You will be able to see the queue1 just created:

您将能够看到刚刚创建的queue1:

The dbo.QueueMessage contains the messages created in the queues. In MASE, go to tables and create a new table:

dbo.QueueMessage包含在队列中创建的消息。 在MASE中,转到表并创建一个新表:

We will create a table named Table1. You can press Add to create a new table and add new properties to the table.

我们将创建一个名为Table1的表。 您可以按添加以创建一个新表并将新属性添加到表中。

The following query will show the table created:

以下查询将显示创建的表:

The Azure local storage is used for development purpose only. It should not be used in production because:

Azure本地存储仅用于开发目的。 不应将其用于生产中,因为:

  • It does not offer security. It uses a specific account.

    它不提供安全性。 它使用一个特定的帐户。
  • It is a simple SQL Server LocalDB instance, and therefore it does not support a heavy workload and it is not designed to have good performance.

    它是一个简单SQL Server LocalDB实例,因此它不支持繁重的工作负载,并且设计得不具有良好的性能。
  • The limit supported for the blob size is 2 GB.

    支持的Blob大小限制为2 GB。

Note: It is also possible to run the emulator in Docker.

注意:也可以在Docker中运行模拟器。

结论 (Conclusion)

In this article, we learned that we can simulate the Azure Storage Account behavior using the emulator which:

在本文中,我们了解到可以使用以下模拟器来模拟Azure存储帐户的行为:

  • works on the command line and you can start or stop it using commands.

    在命令行上工作,您可以使用命令启动或停止它。
  • allows saving the money that Azure may charge if we load data in the Azure Storage Account to test.

    如果我们在Azure存储帐户中加载数据进行测试,则可以节省Azure可能收取的费用。
  • stores all the information in SQL Server tables using the SQL Server LocalDB.

    使用SQL Server LocalDB将所有信息存储在SQL Server表中。

Also, we learned how to use the AzureStorageEmulator.exe.config

此外,我们还学习了如何使用AzureStorageEmulator.exe.config

We also reviewed how to create Azure Containers, upload and download files using the emulator. Finally, we created some queues and tables in the Azure emulator and checked where they are stored. This emulator is for Windows, but if you need to run on Linux, there is a version named Azurite. You can download the Linux version .

我们还回顾了如何创建Azure容器,如何使用模拟器上传和下载文件。 最后,我们在Azure仿真器中创建了一些队列和表,并检查了它们的存储位置。 该仿真器适用于Windows,但是如果您需要在Linux上运行,则有一个名为Azurite的版本。 您可以在下载Linux版本。

翻译自:

azure 免费帐户注册

转载地址:http://vgiwd.baihongyu.com/

你可能感兴趣的文章
Team Foundation Service更新:改善了导航和项目状态速查功能
查看>>
WordPress资源站点推荐
查看>>
Python性能鸡汤
查看>>
android Manifest.xml选项
查看>>
Cookie/Session机制具体解释
查看>>
ATMEGA16 IOport相关汇总
查看>>
JAVA基础-多线程
查看>>
面试题5:字符串替换空格
查看>>
[Codevs] 线段树练习5
查看>>
Amazon
查看>>
component-based scene model
查看>>
Echart输出图形
查看>>
hMailServer搭建简单邮件系统
查看>>
从零开始学习jQuery
查看>>
Spring+SpringMVC+MyBatis深入学习及搭建(四)——MyBatis输入映射与输出映射
查看>>
opacity半透明兼容ie8。。。。ie8半透明
查看>>
CDOJ_24 八球胜负
查看>>
Alpha 冲刺 (7/10)
查看>>
一款jQuery打造的具有多功能切换的幻灯片特效
查看>>
SNMP从入门到开发:进阶篇
查看>>