是否可以在本地(或管道中)通过托管标识访问 Azure 应用程序配置,而无需向 Azure 部署任何其他服务?
我有一个 .net core 单元测试项目,它针对实时站点运行一些集成测试。为了将各种设置、秘密等保留在源代码之外,我想我也许可以使用 Azure 应用程序配置。
我正在阅读本指南,但它似乎旨在访问应用程序配置的应用程序服务https://learn.microsoft.com/en-us/azure/azure-app-configuration/howto-integrate-azure-management-service -身份?标签= core2x
我已启用系统分配的托管标识
[
]1]
并尝试使用以下代码:
var builder = new ConfigurationBuilder();
builder.AddAzureAppConfiguration(options =>
{
options.Connect(new Uri("https://sauitest-config.azconfig.io"), new DefaultAzureCredential())
.Select(KeyFilter.Any, "TestLocal");
});
Run Code Online (Sandbox Code Playgroud)
不幸的是这会返回一个403 (Forbidden). 注意我以管理员身份登录 Visual Studio,使用的凭据与访问门户所用的凭据相同。显然DefaultAzureCredential应该在本地和天蓝色环境中工作。
我在这里错过了什么吗?
我们最近将一些项目升级到.net framework 4.7.1,但我们的内部部署构建代理无法运行构建解决方案构建步骤.我们正在使用Visual Studio Team Services.
完整的错误是......
C:\ Program Files(x86)\ Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1122,5)C:\ Program Files(x86)\ Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1122,5):错误MSB3644:找不到框架".NETFramework,Version = v4.7"的引用程序集.要解决此问题,请为此框架版本安装SDK或Targeting Pack,或者将应用程序重新定位到已安装SDK或Targeting Pack的框架版本.请注意,程序集将从全局程序集缓存(GAC)中解析,并将用于代替引用程序集.因此,您的程序集可能无法正确定位到您想要的框架.
构建机器是安装了Visual Studio 2017,15.4.4的Windows Server 2016 azure VM.我从这里手动安装了4.7.1 .net框架sdk:https://docs.microsoft.com/en-us/dotnet/framework/whats-new/index#v471.
我重新启动并重新启动了代理服务,但仍然失败了以上.
有任何想法如何解决这个问题?
可以在此处找到完整的构建解决方案日志文件:构建解决方案日志要点
谢谢,
我似乎无法在ansible playbook中运行docker compose任务.我陷入了困境.
运行时遇到的第一个错误sudo ansible-playbook playbook.yml如下
fatal: [10.0.3.5]: FAILED! => {"changed": false, "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: No module named compose"}
Run Code Online (Sandbox Code Playgroud)
所以我远程sudo pip install docker-compose到那台机器,并尝试再次运行剧本.这次我得到......
fatal: [10.0.3.5]: FAILED! => {"changed": false, "msg": "Cannot have both the docker-py and docker python modules installed together as they use the same namespace and cause a corrupt installation. Please uninstall both packages, and re-install only the docker-py or docker python module"}
Run Code Online (Sandbox Code Playgroud)
所以我尝试卸载docker python ...
sudo …I'm attempting to access Azure Service Bus using a managed identity from my code. At the moment I'm just trying this locally.
When I debug my code I get the following error
System.UnauthorizedAccessException: Put token failed. status-code: 401, status-description: InvalidIssuer: Token issuer is invalid
Here is my service bus instance
Here is my user with Azure Service Bus Data Owner permissions
And here is my code
_client = new ServiceBusClient("oconnorevents.servicebus.windows.net", new DefaultAzureCredential());
Run Code Online (Sandbox Code Playgroud)
I am logged into Visual Studio as the …
我一直试图理解as#/ await和C#中的任务,但是尽管观看了YouTube视频,阅读文档和遵循复数课程,但仍然失败了.
我希望有人可以帮助回答这些略微抽象的问题,以帮助我的大脑.
1.为什么他们说async/await在它自己的async关键字什么都不做并且await关键字添加一个暂停点时启用'asynchonrous'方法?是不是添加了一个暂停点,强制该方法同步动作,即在继续之前完成await标记的任务.
2.显然除了事件处理程序之外你不应该使用async void,那么你如何正常调用异步方法呢?似乎为了使用await关键字调用异步方法,调用它本身的方法/类需要标记为async.我见过的所有示例都"启动"了一个带有事件处理程序的异步void方法.你如何"逃避"async/await的包装以运行该方法?
3.
public async Task SaveScreenshot(string filename, IWebDriver driver)
{
var screenshot = driver.TakeScreenshot();
await Task.Run(() =>
{
Thread.Sleep(2000);
screenshot.SaveAsFile(filename, ScreenshotImageFormat.Bmp);
Console.WriteLine("Screenshot saved");
});
Console.WriteLine("End of method");
}
Run Code Online (Sandbox Code Playgroud)
回到1.这看起来像一个同步方法.执行在到达时暂停Task.Run,因此Console.WriteLine("End of method");在任务完成之前不会执行.也许整个方法本身将在代码中触发它时异步执行?但回到2,你需要等待调用它,否则你得到消息'因为这个调用是不等的...'因此添加await将导致该执行点是同步的等等.
任何帮助理解这一点将非常感激.
我正在尝试使用 Material UI 样式组件 API 来注入自定义主题和特定自定义元素的一些道具。
我有一个自定义主题或一些道具,但不能同时使用
我的自定义主题在单独的文件中定义如下......
export interface ITheme extends Theme {
sidebar: SideBarTheme;
}
type SideBarTheme = {
// Various properties
};
const theme = createMuiTheme(
{
// Normal theme modifications
},
{
sidebar: {
// Custom theme modifications
},
} as ITheme
);
Run Code Online (Sandbox Code Playgroud)
然后我将其与 Material-UI 样式的组件 API 一起使用,如下所示......
const Profile = styled(Button)(({ theme }: { theme: ITheme }) => ({
backgroundColor: theme.sidebar.profile.backgroundColor,
paddingTop: 20,
paddingBottom: 20
}));
Run Code Online (Sandbox Code Playgroud)
这在我的 jsx 中工作得很好<Profile />。
我正在寻找一种添加自己的附件以测试结果的方法,以便在此处构建完成后可以看到它们。
我想以编程方式在构建过程中以及测试失败后添加这些内容。附件将是屏幕截图。
这可能吗?
我快速浏览了一下API参考,但这似乎与将附件添加到现有测试“运行”有关,或者在构建方面是用于创建构建定义并触发它们。我可能错过了它,但是在测试任务完成期间或之后,我找不到如何从代码中添加附件的方法。
谢谢,
我有以下简单的 powershell 将 zip 文件夹(包含其他文件夹和仅日志文件)解压缩到目的地
$FolderPath = "C:\Temp\Whatever"
Expand-Archive -Path "$FolderPath\logs.zip" -DestinationPath "$FolderPath\logs"
Run Code Online (Sandbox Code Playgroud)
不幸的是,这会返回一大堆错误,如下所示......
Remove-Item : Cannot find path 'C:\Temp\Whatever\logs\1_Selenium SEPA-Test\Attempt1\1_Start VM's\Release\1_Initialize Agent.log' because it does not exist.
At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:410 char:46
+ ... $expandedItems | % { Remove-Item $_ -Force -Recurse }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Temp\Whateve...alize Agent.log:String) [Remove-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Cannot find path 'C:\Temp\Whatever\logs\1_Selenium SEPA-Test\Attempt1\1_Start VM's\Release\1_Initialize Job.log' because it does not exist.
At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:410 char:46
+ ... $expandedItems | % { Remove-Item …Run Code Online (Sandbox Code Playgroud) 如果我在 ACR 存储库中有以下标签和清单...
当我运行以下命令时,它会返回以下内容...
az acr repository show-manifests --name "[registry-name]" --repository "[repository-name]"
Run Code Online (Sandbox Code Playgroud)
[
{
"digest": "sha256:30be2b07e723b0f36fed370c386b027e52dbcd0ad2ad2fcac1d3b7d1b361292f",
"tags": [
"982878",
"master"
],
"timestamp": "2022-09-07T15:49:04.4187041Z"
}
]
Run Code Online (Sandbox Code Playgroud)
当我运行以下清除命令时......
az acr run --cmd "acr purge --filter '[repository-name]:.*' --untagged --ago 1m" --registry [registry-name] /dev/null
Run Code Online (Sandbox Code Playgroud)
它正在删除标签和清单,并且因为它删除了所有内容,所以存储库也被删除。
为什么当我使用该标志时它会这样做,--untagged并且您可以清楚地看到它没有根据起始状态取消标记?
当vscode调试我无法读取appsettings.json我的Startup.cs我的WebAPI项目的文件。它们都返回为空/空。
我launch.json的 webapi 配置是通过添加.NET Core Launch (console)配置生成的。我也尝试添加.NET Core Launch (web)配置,但出现同样的问题。
然后我唯一需要更改的是"program"指向项目文件夹中正确 dll的设置。
这是我的 launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/SATestUtils.API/bin/Debug/netcoreapp3.1/SATestUtils.API.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
}
]
}
Run Code Online (Sandbox Code Playgroud)
这是我的 tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/SATestUtils.Api/SATestUtils.API.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}, …Run Code Online (Sandbox Code Playgroud) c# ×3
azure ×2
azure-devops ×2
ansible ×1
async-await ×1
asynchronous ×1
build-agent ×1
material-ui ×1
powershell ×1
reactjs ×1
typescript ×1