Tag: azure

Azure移动应用程序自定义json序列化

我似乎无法在Azure移动应用程序中自定义JSON序列化。 为了避免我自己的代码的复杂性,我从头开始设置一个新项目。 Visual Studio Community 2015 Update 2,Azure App Service Tools v2.9(如果重要)。 新项目,Visual C#,云,Azure移动应用程序。 在App_Start\Startup.MobileApp.cs这是模板中的内容: public static void ConfigureMobileApp(IAppBuilder app) { HttpConfiguration config = new HttpConfiguration(); new MobileAppConfiguration() .UseDefaultConfiguration() .ApplyTo(config); // Use Entity Framework Code First to create database tables based on your DbContext Database.SetInitializer(new MobileServiceInitializer()); MobileAppSettingsDictionary settings = config.GetMobileAppSettingsProvider().GetMobileAppSettings(); if (string.IsNullOrEmpty(settings.HostName)) { app.UseAppServiceAuthentication(new AppServiceAuthenticationOptions […]

AZURE:在workerrole中异步运行Run()

我有一个异步任务。 async Task UploadFiles() { } 我想在azure workerrole的Run()方法中对UploadFiles()调用’await’。 但’await’仅适用于声明为异步的方法。 所以我可以像下面那样使Run()方法异步: public override void Run() { UploadFiles(); } 至 public async override void Run() { await UploadFiles(); }

AuthenticationContext.AcquireTokenAsync是C#的新手

我是Azure新手,希望能够以编程方式从Azure获取令牌。 无论我做什么,它似乎都失败了 – 有没有人有一个有效的例子? 多谢你们 我调用GetAToken().Wait(); 。 方法是: public async Task GetAToken() { // authentication parameters string clientID = “*********”; string username = “”; string password = “”; string directoryName = “”; ClientCredential cc = new ClientCredential(clientID, password); var authenticationContext = new AuthenticationContext(“https://login.windows.net/” + directoryName); AuthenticationResult result = await authenticationContext.AcquireTokenAsync(“https://management.core.windows.net/”, cc); if (result == null) […]

配置entity framework以从Azure CloudConfiguration文件中选择连接字符串?

我们在Web角色和工作者角色中使用EF-6。 这些角色封装在单个云服务项目中。 为了更好地管理配置设置,我们已将大部分配置密钥移至云项目中,并使用CloudConfigurationManager读取它们。 但对于像Entity Framework或Enterprise Library这样的软件包,我们无法告诉AppDomain从Cloud Config文件中读取设置。 EF查看项目的相应App.Config或Web.Config。 有没有办法告诉EF从云配置文件中读取连接字符串?

直接从流上传到azure异步

我想直接使用流上传到我的azure本地开发帐户。 我已经为azure blob存储创建了一个类。 public class AzureBlob { delegate void UploadFinished(IAsyncResult result); public void uploadFile() { //Initial configuration CloudStorage account = CloudStorageAccount.DevelopmentStorageAccount; CloudBlobClient client = account.CreateBlobClient(); CloudBlobContainer container = client.GetContainerReference(“myfiles”); Stream stream = new MemoryStream(); //Upload to azure CloudBlob blob = container.GetBlobReference(“sample.txt”); UploadFinished uploadFinished = delegate(IAsyncResult result) { Console.WriteLine(“Upload finished {0} {1}”, result.IsCompleted, stream.Position); }; blob.BeginUploadFromStream(stream, […]

如何使用非交互式身份validation连接到Power BI API?

用C#编码。 我正在遵循这个指南: https://azure.microsoft.com/en-us/documentation/articles/resource-group-authenticate-service-principal/#authenticate-service-principal-with-password—powershell%E2%80%8C%E2 %80%8B 但它不起作用而且不是Power BI特定的,因此我不确定如何将其应用于Power BI API。 在我尝试连接到Power BI时,我收到403 Forbidden响应。 var authenticationContext = new AuthenticationContext(“https://login.windows.net/” + Properties.Settings.Default.TenantID); var credential = new ClientCredential(clientId: Properties.Settings.Default.ClientID, clientSecret: Properties.Settings.Default.ClientSecretKey); var result = authenticationContext.AcquireToken(resource: “https://management.core.windows.net/”, clientCredential: credential); if (result == null) { throw new InvalidOperationException(“Failed to obtain the JWT token”); } string accessToken = result.AccessToken; string responseContent = string.Empty; […]

从DocumentDB查询POCO实体

我正在关注Microsoft测试DocumentDB的这篇博客文章 。 我创建了一个集合,并在我的应用程序中通过不同的POCO类插入了2个文档。 它创建了文档,但我无法将它们过滤回各自的POCO类。 我意识到我正在查询所有集合,因此它显然正在检索存储在该集合中的所有文档。 在查询时区分文档的最佳方法是什么,以便我可以按类型单独查询它们? 我可以在文档中添加一个类型字段,并且可以通过WHERE type=”user”获取,但我不确定我不能用users是文档类型的SELECT * FROM users (如果在DocumentDB中有这样的东西),不是一个集合。 以下是我创建文档的方法: var user1= new User() { UserTypeId = 0, UserName = “user1@hotmail.com”, Password = “12345”, PasswordSalt = “saltyPassword”, UserStatusId = 1, ProfilePhotoKey = “KJSY” }; await DocumentDBRepository.CreateItemAsync(user1); var client = new Client() { ClientName = “client1”, Secret = “rxPBsIVYya2Jg2ZHPNG8gL0P36TnutiBehvEFgk938M=”, Title = “Administration Front […]

我们如何跟踪azure文件存储文件夹是否更新?

我有azure色的文件存储,里面有其他文件夹。 我想检查或跟踪该文件夹的上次更新时间? 我做了一个简单的控制台应用程序来获取该位置的所有文件 – // Get list of all files/directories on the file share CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings[“storageConnectionString”]); CloudFileClient fileClient = cloudStorageAccount.CreateCloudFileClient(); CloudFileShare fileShare = fileClient.GetShareReference(ConfigurationManager.AppSettings[“shareName”]); var sourceName = fileShare.GetRootDirectoryReference().GetDirectoryReference((ConfigurationManager.AppSettings[“sourceName”])); IEnumerable fileList = sourceName.ListFilesAndDirectories(); CloudFileDirectory destinationDir = fileShare.GetRootDirectoryReference().GetDirectoryReference((ConfigurationManager.AppSettings[“destinationName”])); foreach (IListFileItem listItem in fileList) { // gives me all file records } 我试着像这样得到它,但它是null 。 var test […]

多语言网站:Azure部署的行为与localhost不同

编辑:完整的代码可以在github存储库中找到。 我已经在这篇文章 (1)和多语言网站的MVC4代码 (2)之后构建了一个ASP.NET MVC5多语言应用程序。 在(2)它使用“技巧”来解决“我希望在语言Y中呈现完整的X.cshtml”问题:它添加了一个后缀ViewName.fr.cshtml,以便视图自动重定向到正确的语言。 这是代码,我认为这是与我的问题相关的代码的唯一部分: public class LocalizedViewEngine : RazorViewEngine { public override ViewEngineResult FindPartialView (ControllerContext controllerContext, string partialViewName, bool useCache) { List searched = new List(); if (!string.IsNullOrEmpty(partialViewName)) { ViewEngineResult result; result = base.FindPartialView(controllerContext, string.Format(“{0}.{1}”, partialViewName, CultureInfo.CurrentUICulture.Name), useCache); if (result.View != null) { return result; } searched.AddRange(result.SearchedLocations); result = base.FindPartialView(controllerContext, string.Format(“{0}.{1}”, partialViewName, […]

Service Bus 1.1使用WindowsAzure.ServiceBus dll创建队列

我正准备开发连接到Azure Service Bus的应用程序。 对于开发,我想使用Service Bus 1.1。 我已经安装了localy Service Bus 1.1,当我连接Service Service.v1_1 ver时,它工作正常。 1.0.5 。 但是,正如我想最终使用Azure,我更喜欢使用WindowsAzure Service Bus,我知道sholud与Service Bus 1.1一起使用。 但是当我想执行时: namespaceManager.QueueExists(queueName) 使用WindowsAzure.ServiceBus ver 3.1.2包我收到: ‘System.ArgumentException’ …. The remote server returned an error: (400) Bad Request. The api-version in the query string is not supported. Either remove it from the Uri or use one of ‘2012-03,2012-08,2013-04,2013-07’. […]