我正在尝试创建一个带有博客触发器的webjob,并且我的动机是创建一个新的博客在容器中上传时自动执行某些过程。
我已经编写了几行代码来测试我的webjob工作与否的天气,但它没有工作并且丢失了以下错误:
Microsoft.WindowsAzure.Storage.StorageException was unhandled
HResult=-2146233088
Message=The remote server returned an error: (400) Bad Request.
您能否帮我解决问题:
我正在附加快照,无论我写什么来实现这一点。
答案 0 :(得分:1)
我无法重现这个问题。看下面的代码示例对我来说很好。
static void Main()
{
CreateDemoData();
// The connection string is read from App.config
JobHost host = new JobHost();
host.RunAndBlock();
}
private static void CreateDemoData()
{
string connectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.Storage);
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("input");
container.CreateIfNotExists();
CloudBlockBlob blob = container.GetBlockBlobReference("BlobOperations.txt");
blob.UploadText("Hell!");
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
CloudQueue queue = queueClient.GetQueueReference("persons");
queue.CreateIfNotExists();
Person person = new Person()
{
Name = "Mohit",
Age = 30
};
queue.AddMessage(new CloudQueueMessage(JsonConvert.SerializeObject(person)));
}
参考Git Hub项目:Microsoft Azure WebJobs SDK Samples