我正在尝试创建一个简单的webhook来接收来自Nexmo SMS服务的送货回执.他们网站上唯一的文件就是这个.
During account set-up, you will be asked to supply Nexmo a CallBack URL for Delivery Receipt to which we will send a delivery receipt for each of your SMS submissions. This will confirm whether your message reached the recipient's handset. The request parameters are sent via a GET (default) to your Callback URL and Nexmo will be expecting response 200 OK response, or it will keep retrying until the Delivery Receipt expires (up to 72 hours).
我一直在寻找这样做的方法,到目前为止,我从网上找到的一个例子中得到了这个方法,虽然我不确定这是否正确.无论如何,这是在ASP.NET和端口6563上运行,所以这是我应该听的端口吗?我下载了一个名为ngrok的应用程序,它应该将我的本地Web服务器暴露给互联网,所以我运行了应用程序并指示它监听端口6563,但没有运气.我一直在试图找到一些帖子来发布这个功能.
[HttpPost] …
Run Code Online (Sandbox Code Playgroud) 所以我正在使用azure移动服务后端来尝试制作自定义API.但是我似乎无法从客户端连接到模板表.使用模板创建新的Azure移动服务时,它们会为您提供values
类似于此格式的API控制器
[MobileAppController]
public class ValuesController : ApiController
{
// GET api/values
[Route("api/values")]
public string Get()
{
return "test";
}
}
Run Code Online (Sandbox Code Playgroud)
从客户端我试图像这样调用这个端点
var result = mobileService.InvokeApiAsync<string>("values", HttpMethod.Get, null).Result;
Run Code Online (Sandbox Code Playgroud)
由于某种原因,我一直得到这个例外
{"The request could not be completed. (Bad Request)"}
{Method: GET, RequestUri: 'http://localhost:58457/api/values', Version: 1.1, Content: <null>, Headers:
{
X-ZUMO-FEATURES: AT
X-ZUMO-INSTALLATION-ID: b04f4e19-4f41-46ed-9767-9c1352037559
Accept: application/json
User-Agent: ZUMO/1.3
User-Agent: (lang=Managed; os=Windows; os_version=6.1.65536.7601; arch=Win32NT; version=1.3.30324.0)
X-ZUMO-VERSION: ZUMO/1.3 (lang=Managed; os=Windows; os_version=6.1.65536.7601; arch=Win32NT; version=1.3.30324.0)
}}
这也只是模板,所以在我启动并运行任何自定义端点之前,我需要这个工作.关于问题可能是什么的任何想法?
所以我有一个 T4 模板,我试图在设计时运行,但它一直给我以下错误。
Running transformation: System.IO.FileNotFoundException: Could not load
file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system
cannot find the file specified.
File name: 'System.Runtime, Version=4.2.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'
Run Code Online (Sandbox Code Playgroud)
我的 Visual Studios 解决方案包含 10 个项目,所有项目都针对 .Net Core 2.0 框架。我的 T4 模板目前看起来是这样的:
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Reflection" #>
<#@ import namespace="Services.Resources.DataTransferObjects.Infrastructures" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ assembly name="$(TargetDir)Services.dll" #> …
Run Code Online (Sandbox Code Playgroud) 我有一个基本的用户表,其中他们可以熟练掌握各种乐器。我无法弄清楚创建基本updateUser
功能的正确方法,他们可以在其中更新用户信息,以及使用 Typeorm 和 MySQL 数据库的仪器熟练程度。
@Entity()
@ObjectType()
export class User extends BaseEntity {
public constructor(init?:Partial<User>) {
super();
Object.assign(this, init);
}
@Index({ unique: true})
@Column()
email: string;
@Index({ unique: true})
@Column()
username: string;
@Column()
@HideField()
password: string;
@Column({
nullable: true
})
profilePicture?: string;
@Index({ unique: true})
@Column()
phoneNumber: string;
//Lazy loading
@OneToMany(() => UserInstrument, p => p.user, {
cascade: true
})
instruments?: Promise<UserInstrument[]>;
}
Run Code Online (Sandbox Code Playgroud)
@Entity()
@ObjectType()
export class UserInstrument extends BaseEntity {
public constructor(init?:Partial<UserInstrument | InstrumentProficiencyInput>) { …
Run Code Online (Sandbox Code Playgroud) 我最近将 Azure 应用服务和 Azure SQL Server 配置为使用托管身份访问。应用服务具有系统分配的托管标识,并具有作为 SQL 数据库所有者的正确分配角色。当我将代码发布到应用程序服务时,它工作得很好并且能够访问数据库。
我的问题是,当通过 Visual Studio 在本地运行应用程序时,我无法通过应用程序连接到数据库。我的 Azure 帐户设置为 SQL Server 上的 Azure Active Directory 管理员,登录后我可以打开连接并通过 Azure Data Studio 运行查询。
我通过 Visual Studio 使用相同的帐户,甚至在“工具”->“选项”->“Azure 服务身份验证/帐户选择”下取消链接并重新链接它。但是,当我尝试在本地运行该应用程序时,我收到错误ManagedIdentityCredential authentication unavailable. Multiple attempts failed to obtain a token from the managed identity endpoint.
该错误并没有给我太多帮助,因为我不确定如何查看正在尝试进行身份验证的内容的完整视图。我没有使用任何代码来获取访问令牌,因为我只是让 Microsoft SQLClient 通过连接字符串为我获取它。
这是错误的完整堆栈跟踪,任何可以为我指明正确方向的内容都将不胜感激。我的猜测是,这与 Visual Studios 有关,可能需要允许代表我获取访问令牌,但我认为既然我登录了我的 Azure 帐户,这可能并不重要。
at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e)
at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, …
Run Code Online (Sandbox Code Playgroud) azure azure-sql-database asp.net-core azure-managed-identity
我有以下2种扩展方法
namespace Services.Resources.Extensions
{
public static class DataMapExtensions
{
public static T ToDTO<T>(this BaseModel model)
{
return Mapper.Map<T>(model);
}
public static List<T> ToDTO<T>(this List<BaseModel> models)
{
return Mapper.Map<List<T>>(models);
}
}
}
Run Code Online (Sandbox Code Playgroud)
第一种方法非常好.
//Note: FlightRoute inherits BaseModel
FlightRouteDTO foo = new FlightRoute().ToDTO<FlightRouteDTO>(); //This works!
Run Code Online (Sandbox Code Playgroud)
但是,第二种方法似乎不起作用.
List<FlightRouteDTO> bar = new List<FlightRoute>().ToDTO<FlightRouteDTO>(); //This doesn't work!
Run Code Online (Sandbox Code Playgroud)
编译器说
错误CS1929'List <FlightRoute>'不包含'ToDTO'的定义,并且最佳扩展方法重载'DataMapExtensions.ToDTO <FlightRouteDTO>(List <BaseModel>)'需要类型为'List <BaseModel>'的接收器
但是FlightRoute
类型BaseModel
.如果我bar
明确地改变了类型,List<BaseModel> ...
那么问题就会消失.
List<FlightRouteDTO> bar = new List<BaseModel>().ToDTO<FlightRouteDTO>(); //Why does it only work this way? …
Run Code Online (Sandbox Code Playgroud) 我最近将我的 Azure Functions 项目更改为具有.Net 6 Isolated
运行时,但现在当我部署它时,我的计时器触发器永远不会触发。我浏览了很多类似的帖子,但我所做的任何更改似乎都无法解决它。它在本地运行良好,只是部署后就不行了。
using Microsoft.Extensions.Hosting;
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();
host.Run();
Run Code Online (Sandbox Code Playgroud)
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
namespace MyProj.AzureFunctions
{
public class Functions
{
private readonly ILogger _logger;
public Functions(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<Functions>();
}
[Function("Health")]
public void Health([TimerTrigger("* * * * *")] MyInfo myTimer, ILogger log)
{
log.LogInformation("Health Check Successful.");
}
}
public class MyInfo
{
public MyScheduleStatus ScheduleStatus { get; set; }
public bool IsPastDue { get; set; }
} …
Run Code Online (Sandbox Code Playgroud) c# ×4
azure ×2
asp.net-core ×1
asp.net-mvc ×1
callback ×1
generics ×1
http-post ×1
inheritance ×1
javascript ×1
lazy-loading ×1
t4 ×1
typeorm ×1
typescript ×1
webhooks ×1