【问题标题】:Azure Blob Sdk - REST or SDK? Emulator?Azure Blob Sdk - REST 还是 SDK?模拟器?
【发布时间】:2014-04-26 01:45:02
【问题描述】:

我正在考虑使用 blob 存储来存储一些备份,并且我想以编程方式进行。

第一个问题真的比 SDK 与 REST API 有什么优势吗?

第二个问题如何模拟本地主机上的博客存储?我找到了this article,但我打算改用 asp.net mvc 5 站点。它说有一些模拟器,但只谈论你是否使用云项目。

编辑

我无法安装模拟器

=== Logging started: 4/25/2014  10:34:55 ===
Action start 10:34:55: INSTALL.
Action start 10:34:55: AppSearch.
Action ended 10:34:55: AppSearch. Return value 1.
Action start 10:34:55: FindRelatedProducts.
Action ended 10:34:55: FindRelatedProducts. Return value 1.
Action start 10:34:55: LaunchConditions.
Action ended 10:34:55: LaunchConditions. Return value 1.
Action start 10:34:55: ValidateProductID.
Action ended 10:34:55: ValidateProductID. Return value 1.
Action start 10:34:55: CostInitialize.
Action ended 10:34:55: CostInitialize. Return value 1.
Action start 10:34:55: FileCost.
Action ended 10:34:55: FileCost. Return value 1.
Action start 10:34:55: SetREINSTALLMODE.
Action ended 10:34:55: SetREINSTALLMODE. Return value 1.
Action start 10:34:55: CostFinalize.
Action ended 10:34:55: CostFinalize. Return value 1.
Action start 10:34:55: SetCommandForRunInitialize.
Action ended 10:34:55: SetCommandForRunInitialize. Return value 1.
Action start 10:34:55: InstallValidate.
Action ended 10:34:55: InstallValidate. Return value 1.
Action start 10:34:55: InstallInitialize.
Action ended 10:34:55: InstallInitialize. Return value 1.
Action start 10:34:55: RemoveExistingProducts.
Action ended 10:34:55: RemoveExistingProducts. Return value 1.
Action start 10:34:55: ProcessComponents.
Action ended 10:34:55: ProcessComponents. Return value 1.
Action start 10:34:55: UnpublishFeatures.
Action ended 10:34:55: UnpublishFeatures. Return value 1.
Action start 10:34:55: RemoveRegistryValues.
Action ended 10:34:55: RemoveRegistryValues. Return value 1.
Action start 10:34:55: RemoveShortcuts.
Action ended 10:34:55: RemoveShortcuts. Return value 1.
Action start 10:34:55: RemoveFiles.
Action ended 10:34:55: RemoveFiles. Return value 1.
Action start 10:34:55: InstallFiles.
Action ended 10:34:55: InstallFiles. Return value 1.
Action start 10:34:55: RunInitialize.
Action ended 10:34:55: RunInitialize. Return value 1.
Action start 10:34:55: CreateShortcuts.
Action ended 10:34:55: CreateShortcuts. Return value 1.
Action start 10:34:55: WriteRegistryValues.
Action ended 10:34:55: WriteRegistryValues. Return value 1.
Action start 10:34:55: RegisterUser.
Action ended 10:34:55: RegisterUser. Return value 1.
Action start 10:34:55: RegisterProduct.
Action ended 10:34:55: RegisterProduct. Return value 1.
Action start 10:34:55: PublishFeatures.
Action ended 10:34:55: PublishFeatures. Return value 1.
Action start 10:34:55: PublishProduct.
Action ended 10:34:55: PublishProduct. Return value 1.
Action start 10:34:55: InstallFinalize.
CAQuietExec:  Windows Azure Storage Emulator 3.0.0.0 command line tool
CAQuietExec:  Error: No available SQL Instance was found.
CAQuietExec:  Error 0xfffffff6: Command line returned an error.
CAQuietExec:  Error 0xfffffff6: CAQuietExec Failed
CustomAction RunInitialize returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 10:38:33: InstallFinalize. Return value 3.
Action ended 10:38:34: INSTALL. Return value 3.
Property(S): UpgradeCode = {CF5CD495-AEDE-42DA-B7CF-A70D398D4E6A}
Property(S): RunInitialize = "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\Storage Emulator\WAStorageEmulator.exe" init -forcecreate -autodetect
Property(S): DOTNET4FULL = 4.5.51641
Property(S): LOCALDBINSTALLED = C:\Program Files (x86)\Microsoft SQL Server\110\LocalDB\Binn\SqlUserInstance.dll
Property(S): SQLEXPRESSVERSION = 10.0.2531.0
Property(S): TARGETDIR = G:\
Property(S): StorageEmulatorMenuFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Azure\Storage Emulator\
Property(S): STORAGEEMUDIR = C:\Program Files (x86)\Microsoft SDKs\Windows Azure\Storage Emulator\
Property(S): WixUIRMOption = UseRM
Property(S): ALLUSERS = 1
Property(S): ARPNOMODIFY = 1
Property(S): REINSTALLMODE = amus
Property(S): WindowsAzureMenuFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Windows Azure\
Property(S): ProgramMenuFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\
Property(S): WINDOWSAZUREDIR = C:\Program Files (x86)\Microsoft SDKs\Windows Azure\
Property(S): MICROSOFTSDKSDIR = C:\Program Files (x86)\Microsoft SDKs\
Property(S): ProgramFilesFolder = C:\Program Files (x86)\
Property(S): SourceDir = C:\Users\win8\AppData\Local\Microsoft\Web Platform Installer\installers\WindowsAzureStorageEmulator.3.0\1356EC2B8E2DBE40C737E5555DD11DFA1BE1AB47\
Property(S): MSIRMSHUTDOWN = 1
Property(S): WIXUI_INSTALLDIR = INSTALLDIR
Property(S): ARPSYSTEMCOMPONENT = 1
Property(S): DefaultUIFont = WixUI_Font_Normal
Property(S): WixUI_Mode = Minimal
Property(S): Manufacturer = Microsoft Corporation
Property(S): ProductCode = {6DFDA7BE-32F0-4E6F-B304-3567E656D18C}
Property(S): ProductLanguage = 1033
Property(S): ProductName = Windows Azure Storage Emulator - v3.0
Property(S): ProductVersion = 3.0.6848.39
Property(S): ErrorDialog = ErrorDlg
Property(S): SecureCustomProperties = NEWERVERSIONDETECTED;OLDEMULATORPACKAGEDETECTED;OLDERVERSIONDETECTED
Property(S): WixPdbPath = o:\bttemp\149736\obj.amd64fre\services\xstore\rdpackages\storageemulatorpackage\objfre\amd64\en-us\WindowsAzureStorageEmulator.wixpdb
Property(S): MsiLogFileLocation = C:\Users\win8.hub\AppData\Local\Temp\WindowsAzureStorageEmulator.txt
Property(S): PackageCode = {C5E0C90F-EFDF-4030-8F5D-2A3AF97D8B80}
Property(S): ProductState = -1
Property(S): PackagecodeChanging = 1
Property(S): REBOOT = ReallySuppress
Property(S): CURRENTDIRECTORY = C:\WINDOWS\SysWOW64
Property(S): CLIENTUILEVEL = 3
Property(S): CLIENTPROCESSID = 5180
Property(S): VersionDatabase = 200
Property(S): VersionMsi = 5.00
Property(S): VersionNT = 603
Property(S): VersionNT64 = 603
Property(S): WindowsBuild = 9600
Property(S): ServicePackLevel = 0
Property(S): ServicePackLevelMinor = 0
Property(S): MsiNTProductType = 1
Property(S): WindowsFolder = C:\WINDOWS\
Property(S): WindowsVolume = C:\
Property(S): System64Folder = C:\WINDOWS\system32\
Property(S): SystemFolder = C:\WINDOWS\SysWOW64\
Property(S): RemoteAdminTS = 1
Property(S): TempFolder = C:\Users\win8.hub\AppData\Local\Temp\
Property(S): CommonFilesFolder = C:\Program Files (x86)\Common Files\
Property(S): ProgramFiles64Folder = C:\Program Files\
Property(S): CommonFiles64Folder = C:\Program Files\Common Files\
Property(S): AppDataFolder = C:\Users\win8\AppData\Roaming\
Property(S): FavoritesFolder = C:\Users\win8\Favorites\
Property(S): NetHoodFolder = C:\Users\win8\AppData\Roaming\Microsoft\Windows\Network Shortcuts\
Property(S): PersonalFolder = C:\Users\win8\Documents\
Property(S): PrintHoodFolder = C:\Users\win8\AppData\Roaming\Microsoft\Windows\Printer Shortcuts\
Property(S): RecentFolder = C:\Users\win8\AppData\Roaming\Microsoft\Windows\Recent\
Property(S): SendToFolder = C:\Users\win8\AppData\Roaming\Microsoft\Windows\SendTo\
Property(S): TemplateFolder = C:\ProgramData\Microsoft\Windows\Templates\
Property(S): CommonAppDataFolder = C:\ProgramData\
Property(S): LocalAppDataFolder = C:\Users\win8\AppData\Local\
Property(S): MyPicturesFolder = C:\Users\win8\Pictures\
Property(S): AdminToolsFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools\
Property(S): StartupFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\
Property(S): StartMenuFolder = C:\ProgramData\Microsoft\Windows\Start Menu\
Property(S): DesktopFolder = C:\Users\Public\Desktop\
Property(S): FontsFolder = C:\WINDOWS\Fonts\
Property(S): GPTSupport = 1
Property(S): OLEAdvtSupport = 1
Property(S): ShellAdvtSupport = 1
Property(S): MsiAMD64 = 6
Property(S): Msix64 = 6
Property(S): Intel = 6
Property(S): PhysicalMemory = 8142
Property(S): VirtualMemory = 5083
Property(S): AdminUser = 1
Property(S): MsiTrueAdminUser = 1
Property(S): LogonUser = win8
Property(S): UserSID = S-1-5-21-1097169495-1557939910-592522955-27415
Property(S): UserLanguageID = 1033
Property(S): ComputerName = win8
Property(S): SystemLanguageID = 1033
Property(S): ScreenX = 1024
Property(S): ScreenY = 768
Property(S): CaptionHeight = 23
Property(S): BorderTop = 1
Property(S): BorderSide = 1
Property(S): TextHeight = 16
Property(S): TextInternalLeading = 3
Property(S): ColorBits = 32
Property(S): TTCSupport = 1
Property(S): Time = 10:38:34
Property(S): Date = 4/25/2014
Property(S): MsiNetAssemblySupport = 4.0.30319.33440
Property(S): MsiWin32AssemblySupport = 6.3.9600.16384
Property(S): RedirectedDllSupport = 2
Property(S): MsiRunningElevated = 1
Property(S): Privileged = 1
Property(S): USERNAME = win8
Property(S): DATABASE = C:\WINDOWS\Installer\fab232b.msi
Property(S): OriginalDatabase = C:\Users\win8\AppData\Local\Microsoft\Web Platform Installer\installers\WindowsAzureStorageEmulator.3.0\1356EC2B8E2DBE40C737E5555DD11DFA1BE1AB47\WindowsAzureStorageEmulator.msi
Property(S): UILevel = 2
Property(S): ACTION = INSTALL
Property(S): ROOTDRIVE = G:\
Property(S): CostingComplete = 1
Property(S): OutOfDiskSpace = 0
Property(S): OutOfNoRbDiskSpace = 0
Property(S): PrimaryVolumeSpaceAvailable = 0
Property(S): PrimaryVolumeSpaceRequired = 0
Property(S): PrimaryVolumeSpaceRemaining = 0
Property(S): INSTALLLEVEL = 1
Property(S): SOURCEDIR = C:\Users\win8\AppData\Local\Microsoft\Web Platform Installer\installers\WindowsAzureStorageEmulator.3.0\1356EC2B8E2DBE40C737E5555DD11DFA1BE1AB47\
Property(S): SourcedirProduct = {6DFDA7BE-32F0-4E6F-B304-3567E656D18C}
Property(S): ProductToBeRegistered = 1
MSI (s) (34:88) [10:38:34:039]: Product: Windows Azure Storage Emulator - v3.0 -- Installation failed.

MSI (s) (34:88) [10:38:34:039]: Windows Installer installed the product. Product Name: Windows Azure Storage Emulator - v3.0. Product Version: 3.0.6848.39. Product Language: 1033. Manufacturer: Microsoft Corporation. Installation success or error status: 1603.

=== Logging stopped: 4/25/2014  10:38:34 ===

【问题讨论】:

    标签: azure


    【解决方案1】:

    第一个问题真的比 SDK 与 REST API 有什么优势吗?

    SDK 优于 REST API 对我来说的优势是您不必编写代码来使用 REST API。 SDK(而不是作为 SDK 一部分的存储客户端库)会为您完成这项工作,因此您的上市时间会大大缩短。在 Azure 的早期对 REST API 的更改来得更快,然后在 SDK 中实现这些 REST API 的一段时间后。然而最近它们或多或少是同步的。

    我想说的一件事是,虽然 REST API 和存储客户端库由一个团队(Azure 存储团队)维护,但 SDK(也包含本地存储模拟器)由另一个团队维护,并且它们的发布周期不不经常匹配。一个很好的例子是支持 CORS 的 Storage Client Library v3.x 的发布。当这个版本的库发布时,SDK 仍然是 2.x 版本,只支持 Storage Client Library v2.x,这引起了很多麻烦(例如Azure 400 Bad Request on every request)。所以你可能需要考虑到这一点。

    其次,我假设您将使用 .Net 进行应用程序开发。如果不是这种情况,那么您最好使用 REST API,因为其他语言的存储客户端库仍然无法与最新版本的 REST API 相提并论。

    第二个问题如何模拟本地主机上的blob存储?

    安装 Azure SDK 时,会在该过程中安装本地存储模拟器。您可以使用本地存储模拟器在本地测试 Blob 存储。无需云服务项目即可使用本地存储模拟器。您可以在任何类型的应用程序中使用它。唯一需要注意的是,您必须手动启动本地存储模拟器(如果您调试云服务项目,它将自动启动)。同样,如果您使用的是 .Net 存储客户端库,您可以通过以下两种方式通过代码连接到此本地存储模拟器:

    CloudStorageAccount cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
    

    CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
    

    【讨论】:

    • 感谢您的洞察力,我将使用 sdk,因为这是我的想法,不需要编写代码来连接到 api。所以我只是把那行放在我的 C# 代码中(即 global.asax),但是它保存在我的本地驱动器上的什么地方呢?如何启动本地存储模拟器是程序吗?
    • How do I start the local storage emulator up is it a program? - 假设您使用的是 SDK 2.3 版,您可能会发现这篇文章很有用:gauravmantri.com/2014/04/04/…。启动模拟器的命令是WAStorageEmulator start。不确定So I just put that line in my C# code(ie global.asax) but where does it get saved to on my local drive? 是什么意思。你能解释一下吗?
    • 我认为那行就像一个标志,表明您的所有代码都处于仿真器模式,似乎我需要一个 if 语句来执行上述两行之一,然后是这样的CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));我猜我会使用 web.config 中的连接字符串管理器而不是 CloudConfigurationManage?
    • 啊,我明白了。因此,您可以使用 CloudConfigurationManager,它会从 web.config 的 <appSettings> 部分读取连接字符串(无需在 <connectionString> 部分下定义此连接字符串。
    • 真的如此,我只是制作一个常规的 asppsetting 键和值并使用 CloudConfigurationManager,它会从 appSettings 中获取它吗?与 ConfigurationManager 相比有什么优势吗?我仍然不确定模拟器将文件保存在哪里,但首先我无法通过 Web 平台安装模拟器,因为它一直在失败
    猜你喜欢
    • 2021-11-08
    • 2015-03-18
    • 1970-01-01
    • 2014-10-18
    • 2014-10-20
    • 2015-11-14
    • 2014-09-08
    • 2021-10-05
    • 1970-01-01
    相关资源
    最近更新 更多