使用Azure容器注册表从C#创建新的Azure容器实例
我创建了一个Azure容器注册表,并将自定义ACI上传到注册表 – 没问题 – 一切都按预期工作.我尝试使用Azure门户从映像创建容器实例,并且没有问题 – 但是 – 当我想使用Microsoft Azure管理容器实例Fluent API使用C#自动化时,我遇到问题,即使我感觉我已经遍布互联网和设置,寻找隐藏的障碍物,我一直没有找到太多的帮助.
我的代码如下: var azureCredentials = new AzureCredentials(new ServicePrincipalLoginInformation { ClientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" },"xxxxxxxxxxxxxxxxxxxxxxxxxxxx",AzureEnvironment.AzureGlobalCloud); var azure = Azure .Configure() .Authenticate(azureCredentials) .WithSubscription("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"); IContainerGroup containerGroup = azure.ContainerGroups.Define("mytestgroup") .WithRegion(Region.EuropeWest) .WithExistingResourceGroup("mytest-rg") .WithLinux() .WithPrivateImageRegistry("mytestreg.azurecr.io","mytestreg","xxxxxxxxxxxxxx") .WithoutVolume() .DefineContainerInstance("mytestgroup") .WithImage("mytestimage/latest") .WithExternalTcpPort(5555) .WithCpuCoreCount(.5) .WithMemorySizeInGB(.5) .Attach() .Create(); 上面的代码一直给我一个例外: Microsoft.Rest.Azure.CloudException:’无法访问容器组’mytestgroup’中的图像’mytestimage / latest’.请检查图像和注册表凭据. 我尝试了几件事; >使用docker login测试凭据 – 没问题. 我不知道为什么私有注册表的凭据不起作用 – 我直接从Azure门户复制/粘贴以避免拼写错误,尝试手动输入等. 使用Fiddler检查流量并未发现任何有趣的内容,除了上述异常消息直接从Azure Management API返回. 我遗失的显而易见的事情是什么? 解决方法
上面的答案(即使用完整的azure注册服务器名称):
.WithImage("mytestreg.azurecr.io/mytestimage:latest") 似乎是解决方案的一部分,但即使有了这种改变,我仍然看到了这个错误.通过网络上的其他示例(https://github.com/Azure-Samples/aci-dotnet-create-container-groups-using-private-registry/blob/master/Program.cs)查看我需要的内容,我将azure身份验证更改为: azure = Azure.Authenticate(authFilePath).WithDefaultSubscription(); 至: AzureCredentials credentials = SdkContext.AzureCredentialsFactory.FromFile(authFilePath); azure = Azure .Configure() .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic) .Authenticate(credentials) .WithDefaultSubscription(); 随着这种变化,事情现在正在发挥作用. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows-server-2008 – Powershell使用CNAME远程
- 在Windows 2000中使用Visual Studio 2010编译C D
- Windows中的Bash启动脚本
- SLOW Drupal over localhost | windows7 EasyPHP
- windows-server-2016 – 存储空间直接MTBF
- https – Microsoft.WindowsAzure.ServiceRuntim
- Windows cmd echo/pipe最后会增加额外的空间 –
- x32下的DLL隐藏
- api – 还有可能让Skype的用户在线状态?
- windows – 无法覆盖Meteor absoluteUrl?