我创建了一些使用触发器的Azure Webjobs,我刚刚学习了Azure Functions.
根据我的理解,Azure Functions似乎与Azure Webjobs功能重叠,我有一些难以理解何时在Function和Webjob之间进行选择:
与Webjobs不同,函数只能被触发,它不是为了运行连续过程而设计的(但您可以编写代码来创建连续函数).
您可以使用多种语言编写Webjobs和函数(C#,node.js,python ...),但您可以从Azure门户编写函数,以便更容易,更快地开发测试和部署函数.
Webjobs在App Service Web应用程序,API应用程序或移动应用程序的上下文中作为后台进程运行,而Function则使用Classic/Dynamic App Service Plan运行.
关于缩放,函数似乎提供了更多的可能性,因为您可以使用动态应用程序服务计划,并且您可以扩展单个函数,而对于webjob,您必须扩展整个Web应用程序.
因此,确定存在价格差异,如果您运行现有的Web应用程序,您可以使用它来运行webjob而无需任何额外费用但是如果我没有现有的Web应用程序而且我必须编写代码来触发队列我应该使用webjob还是函数?
您需要选择时还需要记住其他注意事项吗?
我想使用android动画在模拟器上从左到右翻译图像.我是android动画的新手.我怎么能这样做?
谢谢.
如果我有这样的课程:
public class Facet : TableServiceEntity
{
public Guid ParentId { get; set; }
public string Name { get; set; }
public string Uri{ get; set; }
public Facet Parent { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
Parent来自ParentId Guid,该关系旨在由我的存储库填充.那么我如何告诉Azure单独留下该字段?是否存在某种类型的Ignore属性,或者我是否必须创建一个提供这些关系的继承类?
我们在项目中使用服务总线队列.当管理员选择清除队列时,我们需要一种功能来从队列中删除所有消息.我在网上搜索但找不到任何在QueueClient课堂上做这个的功能.
我是否必须逐个弹出所有消息,然后将它们标记为完成以清除队列或者有更好的方法吗?
QueueClient queueClient = _messagingFactory.CreateQueueClient(
queueName, ReceiveMode.PeekLock);
BrokeredMessage brokeredMessage = queueClient.Receive();
while (brokeredMessage != null )
{
brokeredMessage.Complete();
brokeredMessage = queueClient.Receive();
}
Run Code Online (Sandbox Code Playgroud) 通过 Bicep 模块部署存储帐户时是否可以检索存储帐户的访问密钥?
我的父二头肌使用模块文件创建一个存储帐户,然后它需要一个访问密钥,但我无法让它以安全的方式工作:
家长二头肌
module functionAppStorageModule 'storage-account.bicep' = {
name: 'functionAppStorage'
params: {
...
}
}
resource functionApp 'Microsoft.Web/sites@2021-03-01' = {
name: functionAppName
location: location
kind: 'functionapp'
properties: {
siteConfig: {
appSettings: [
{
name: 'store_key'
value: ???
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我在模块文件上设置输出,并在父二头肌中使用该输出,我就可以让它工作:
模块二头肌
output storageAccountStr string = 'AccountKey=${listKeys(storageAccount.id, storageAccount.apiVersion).keys[0].value}'
Run Code Online (Sandbox Code Playgroud)
家长二头肌
properties: {
siteConfig: {
appSettings: [
{
name: 'store_key'
value: functionAppStorageModule.outputs.storageAccountStr
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
但这对我来说似乎并不安全,因为密钥以纯文本形式出现在 Azure 门户上的“部署”输出部分中。
或者,我可以通过预先部署存储帐户而不使用模块文件来解决这个问题,因为模块的使用似乎是问题所在,但只是想知道我上面尝试的内容是不可能的吗?
谢谢
azure azure-storage azure-resource-manager azure-functions azure-bicep
主二头肌
resource appService 'Microsoft.Web/sites@2020-06-01' = {
name: webSiteName
location: location
properties: {
serverFarmId: appServicePlan.id
siteConfig: {
linuxFxVersion: linuxFxVersion
appSettings: [
{
name: 'ContainerName'
value: 'FancyContainer'
}
{
name: 'FancyUrl'
value: 'fancy.api.com'
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
基础结构发布过程成功运行,并且应用程序设置设置正确,之后我运行节点应用程序构建和发布,其中 Azure DevOps 发布管道将一些与应用程序相关的配置添加到应用程序设置。(例如 API 密钥、API URL),一切都运行良好。
但是,如果我必须重新发布基础架构,例如,我使用存储帐户扩展我的环境,则应用程序发布设置的应用程序设置将丢失。
是否有解决方法可以保留 Bicep 模板中未定义的应用程序设置?
azure azure-resource-manager azure-web-app-service azure-bicep
我有一个使用Windows Azure存储客户端3.0工作的基本Azure表存储查询.将此转换为异步查询的最简单方法是什么?是否可以使用异步等待模式?
//Setup the storage account connection
var cloudStorageAccount = CloudStorageAccount.Parse(connectionString);
var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
var table = cloudTableClient.GetTableReference("SampleTable");
//Get the context
var context = cloudTableClient.GetTableServiceContext();
//Setup the query
var q = from s in table.CreateQuery<SampleEntity>()
where s.PartitionKey == sampleUID.ToString()
select s;
//Get the list
var list = q.ToList();
Run Code Online (Sandbox Code Playgroud)
插入和更新实体有XyzAsync()方法......我必须遗漏一些东西.谢谢您的帮助.
我正在运行Azure函数,称为SmsWebhook.它调用外部程序集中的方法,该方法AzureFunctionsSample.Services.dll具有引用Newtonsoft.Json 8.0.3
我的细节Run.csx看起来像:
#r "AzureFunctionsSample.Services.dll"
using System.Net;
using AzureFunctionsSample.Services
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
...
}
Run Code Online (Sandbox Code Playgroud)
在Run()上面的方法中,我创建一个实例并在实例中调用一个方法.但是,每当我调用该方法时,都会收到以下错误:
2016-05-19T13:41:45 Welcome, you are now connected to log-streaming service.
2016-05-19T13:41:46.878 Function started (Id=64fccf0c-d0ef-45ef-ac1c-7736adc94566)
2016-05-19T13:41:46.878 C# HTTP trigger function processed a request. RequestUri=https://ase-dev-fn-demo.azurewebsites.net/api/smswebhook
2016-05-19T13:41:46.878 Function completed (Failure, Id=64fccf0c-d0ef-45ef-ac1c-7736adc94566)
2016-05-19T13:41:46.894 Exception while executing function: Functions.SmsWebhook. Microsoft.Azure.WebJobs.Script: One or more errors occurred. AzureFunctionsSample.Services: Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' …Run Code Online (Sandbox Code Playgroud) 我无法找到任何关于在发布管道中启用自动调整的文档,即通过ARM模板或powershell,也不能在github arm快速入门中找到.
我可以在资源浏览器中看到自动调优,但我没有看到这在ARM模板中如何反映.
{
"name": "Microsoft.Sql/servers/automaticTuning/read",
"display": {
"provider": "Microsoft SQL Database",
"resource": "Server Automatic Tuning",
"operation": "Get automatic tuning settings for the server",
"description": "Returns automatic tuning settings for the server"
}
},
{
"name": "Microsoft.Sql/servers/automaticTuning/write",
"display": {
"provider": "Microsoft SQL Database",
"resource": "Server Automatic Tuning",
"operation": "Update automatic tuning settings for the server",
"description": "Updates automatic tuning settings for the server and returns updated settings"
}
},
Run Code Online (Sandbox Code Playgroud) azure azure-powershell azure-resource-manager azure-sql-database
我发现使用托管标识连接到 Azure KeyVault 很容易。该文档显示了如何做到这一点:
var azureServiceTokenProvider = new AzureServiceTokenProvider();
var keyVaultClient = new KeyVaultClient(
new KeyVaultClient.AuthenticationCallback(
azureServiceTokenProvider.KeyVaultTokenCallback));
config.AddAzureKeyVault(
$"https://{builtConfig["KeyVaultName"]}.vault.azure.net/",
keyVaultClient,
new DefaultKeyVaultSecretManager());
Run Code Online (Sandbox Code Playgroud)
然后我意识到它需要Microsoft.Azure.KeyVault已弃用的包。所以我正在努力弄清楚如何使用 SDK 4 执行上述操作。我找到的所有文档都与 SDK 3 相关。
[编辑] 我发现以下代码可以使用带有 SDK 4 的托管标识来获取 azure KeyVault Secret。但是我看不到如何将它添加到我的配置中。它曾经是通过 config.AddAzureKeyVault()Microsoft.Extensions.Configuration.AzureKeyVault 包完成的,但它与 SDK 4 SecretClient 不兼容:
return Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, config) =>
{
var azureCredentialOptions = new DefaultAzureCredentialOptions();
var credential = new DefaultAzureCredential(azureCredentialOptions);
var secretClient = new SecretClient(new System.Uri("https://mykeyvault.vault.azure.net/"), credential);
var secret = secretClient.GetSecret("StorageConnectionString");
config.AddAzureKeyVault()
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
}); …Run Code Online (Sandbox Code Playgroud)