Tag: azure

如何将Stream上载到Azure Media Services

我们使用ASP.NET MVC 4允许用户通过我们的网站上传video和音频。 我想使用Azure Media Service作为后端。 在遵循Azure的教程时 ,我遇到的问题是Azure Media Services SDK似乎不允许上传原始数据流。 相反,我能找到的唯一上传方法使用路径字符串参数。 我想避免将文件保存到磁盘( 默认情况下它已经流式传输到磁盘 ),并且能够将请求发布的文件直接流式传输到Azure。 到目前为止,这是我的代码: public void SaveMedia(string fileName, System.IO.Stream stream) { CloudMediaContext mediaCloud = new CloudMediaContext(“account”, “key”); AssetCreationOptions assetOptions = new AssetCreationOptions(); var asset = mediaCloud.Assets.Create(fileName, assetOptions); var assetFile = asset.AssetFiles.Create(fileName); var accessPolicy = mediaCloud.AccessPolicies.Create(fileName, TimeSpan.FromDays(3), AccessPermissions.Write | AccessPermissions.List); var locator = mediaCloud.Locators.CreateLocator(LocatorType.Sas, […]

将Application Insights与unit testing结合使用?

我有一个MVC网络应用程序,我正在使用Simple Injector进行DI。 我的几乎所有代码都包含在unit testing中。 但是,现在我在某些控制器中添加了一些遥测调用,我在设置依赖项时遇到了麻烦。 遥测调用用于将指标发送到Microsoft Azure托管的Application Insights服务。 该应用程序未在Azure中运行,只是一个带有ISS的服务器。 AI门户网站会告诉您有关应用程序的各种信息,包括您使用遥测库发送的任何自定义事件。 因此,控制器需要一个Microsoft.ApplicationInsights.TelemetryClient实例,该实例没有接口,并且是一个带有2个构造函数的密封类。 我试着像这样注册它(混合生活方式与这个问题无关,我只是为了完整性而把它包括在内): // hybrid lifestyle that gives precedence to web api request scope var requestOrTransientLifestyle = Lifestyle.CreateHybrid( () => HttpContext.Current != null, new WebRequestLifestyle(), Lifestyle.Transient); container.Register(requestOrTransientLifestyle); 问题是,由于TelemetryClient有2个构造函数,SI抱怨并且validation失败。 我找到了一篇文章,展示了如何覆盖容器的构造函数解析行为,但这似乎相当复杂。 首先,我想备份并提出这个问题: 如果我没有让TelemetryClient成为一个注入的依赖项(只是在类中创建一个新的),那么在每次运行unit testing时是否会将遥测发送到Azure,从而产生大量错误数据? 或者,Application Insights足够聪明,知道它是在unit testing中运行,而不是发送数据? 对此问题的任何“见解”将不胜感激! 谢谢

应用程序抛出web.config被修改的exception,但事实并非如此

我的asp.net网络表单网站上的azure app服务面临着奇怪的问题。 得到例外: ConfigurationErrorsExceptionSystem.Configuration.BaseConfigurationRecord in EvaluateOne The configuration file has been changed by another program. (D:\home\site\wwwroot\web.config) ConfigurationErrorsException: The configuration file has been changed by another program. (D:\home\site\wwwroot\web.config) Module “System.Configuration.BaseConfigurationRecord”, line 72, col 0, in EvaluateOne System.Object EvaluateOne(System.String[], System.Configuration.SectionInput, Boolean, System.Configuration.FactoryRecord, System.Configuration.SectionRecord, System.Object) Module “System.Configuration.BaseConfigurationRecord”, line 515, col 0, in Evaluate Boolean Evaluate(System.Configuration.FactoryRecord, System.Configuration.SectionRecord, System.Object, Boolean, […]

Azure服务总线队列PeekBatch锁定?

我在QueueClient (Windows Azure Service Bus包版本2.1.2.0)上使用PeekBatch()方法。 它第一次工作正常,并返回我的队列中存在的单个消息,但后续调用什么都不返回。 五分钟后,呼叫将再次返回消息。 五分钟是BrokeredMessage上的最大锁定时间,所以我想知道PeekBatch是否实际上像接收那样锁定那些消息,即使偷看不应该锁定,据我所知。 我正在尝试构建一个MVC视图,以便能够看到我的队列中实际存在的内容,但是这个视图正在阻碍。 任何人都可以就此提供任何指导吗? 更新 :当我使用静态属性缓存QueueClient时,似乎只会发生这种情况。 如果我每次都创建新的QueueClient , PeekBatch将按预期工作。 我仍然不知道为什么重用QueueClient会导致这种情况。 微软似乎建议重用QueueClient ,而不是每次都重新创建它,所以我仍然在这里不知所措。

为什么上传到Azure blob这么慢?

我有一个自定义流,用于直接在页面云blob中执行写入操作。 public sealed class WindowsAzureCloudPageBlobStream : Stream { // 4 MB is the top most limit for page blob write operations public const int MaxPageWriteCapacity = 4 * 1024 * 1024; // Every operation on a page blob has to manipulate a value which is rounded up to 512 bytes private const int PageBlobPageAdjustmentSize = […]

从代码(c#)部署Azurefunction

如何将代码为字符串(在c#中)的azure函数(按计划执行)部署到给定的azure函数应用程序? 我将使用ARM模板部署azure fund app(+所有它需要的) https://github.com/Azure/azure-quickstart-templates/tree/master/101-function-app-create-dynamic ,它可以通过代码部署; 但我没有看到通过代码部署function到应用程序的方法。 +更多上下文 :部署将从应用服务发生,因此除了NuGet之外,最好不要有任何依赖。 例如,我不喜欢从c#调用azure cli的想法。

Visual Studio 2013解决方案构建不在构建顺序中

我在使用C#解决方案构建“Fresh”时遇到了问题。 如果我清理解决方案并再次构建它将无法构建(我可以做几次并且它将构建)。 它有一个关于azure项目在它依赖的worker和web项目之前构建的错误。 还有关于解决方案中的大多数项目是如何寻找的 WAT070 : The referenced assembly {…}/Worker.dll was not found. Please make sure to build the role project that produces this assembly before building this Windows Azure Cloud Service Project. {…}\VisualStudio\v12.0\Windows Azure Tools\2.2\Microsoft.WindowsAzure.targets 1252 5 AzureProjectName 现在,如果我按照项目依赖项中列出的顺序构建项目 – >构建顺序一切正常。 此外,在Azure项目之前列出了Web和工作角色。

如何将带有.MDF文件(Sql 2008)的现有ASP.NET MVC 3项目迁移到Windows Azure模拟器(使用SQL Azure)

我在Visual Studio 2010中使用现有项目,使用.mdf(SQL 2008 Express)的现有数据库使用ASP.NET MVC 3。 做了一些谷歌搜索,我感到困惑,因为有太多的资源。 你能帮我指出一下简单的教程链接吗?

批量上载大量图像到Azure Blob存储

我有大约110,000张各种格式的图像(jpg,png和gif)和大小(2-40KB)本地存储在我的硬盘上。 我需要将它们上传到Azure Blob存储。 在执行此操作时,我需要设置一些元数据和blob的ContentType,否则它是直接批量上传。 我目前正在使用以下内容来处理一次上传一个图像(并行超过5-10个并发任务)。 static void UploadPhoto(Image pic, string filename, ImageFormat format) { //convert image to bytes using(MemoryStream ms = new MemoryStream()) { pic.Save(ms, format); ms.Position = 0; //create the blob, set metadata and properties var blob = container.GetBlobReference(filename); blob.Metadata[“Filename”] = filename; blob.Properties.ContentType = MimeHandler.GetContentType(Path.GetExtension(filename)); //upload! blob.UploadFromStream(ms); blob.SetMetadata(); blob.SetProperties(); } } 我想知道是否还有其他技术可以用来处理上传,以尽可能快地完成。 此特定项目涉及将大量数据从一个系统导入另一个系统,并且出于客户原因,它需要尽快发生。

Azure Redis缓存 – ConnectionMultiplexer对象池

我们在我们的应用程序中使用C1 Azure Redis Cache。 最近我们在GET操作上遇到了很多时间。 根据这篇文章 ,可能的解决方案之一是实现ConnectionMultiplexer对象池。 另一种可能的解决方案是在客户端中使用ConnectionMultiplexer对象池,并在发送新请求时选择“负载最小”的ConnectionMultiplexer。 这应该可以防止单个超时导致其他请求也超时。 如何使用C#实现一个ConnectionMultiplexer对象池? 编辑: 我最近问的相关问题。