尝试在 Visual Studio Code 中调试一个简单的 HTML 和 JavaScript 项目。在 VS Code 终端窗口中,“live-server”用于启动“index.html”。在 VS Code 中,安装并配置了“Chrome 调试器”。即使在 Chrome 浏览器中启动页面后,调试器也不会附加并给出错误消息“无法连接到运行时进程,10000 毫秒后超时 - (原因:无法连接到目标:连接 ECONNREFUSED 127.0.0.1:9222) .'。
启动文件
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"webRoot": "${workspaceRoot}",
"urlFilter": "http://localhost:8080"
},
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against index.html",
"file": "${workspaceRoot}/index.html"
}
]
Run Code Online (Sandbox Code Playgroud)
Chrome 的快捷方式修改为包括 --remote-debugging-port=9222
是否可以在 JavaScript 文件的 VS Code 中使用“实时服务器”并调试或设置断点?
我试图通过Azure资源管理器创建一个网站,然后从私有Github存储库进行部署.
我有一个适用于公共存储库的ARM模板.如果我然后将存储库设为私有,请通过Portal连接到它,一切正常.
如果我重新部署ARM模板,它将失败并显示消息
"Cannot find SourceControlToken with name GitHub."
Run Code Online (Sandbox Code Playgroud)
似乎当门户连接到私有仓库时,它将创建一个用于进行身份验证的ssh密钥.
ssh密钥似乎来自kudu,可以在部署站点后获得.
我也尝试过使用访问令牌,但无法使用访问令牌
所以简单的问题是,如何通过ARM模板部署私有仓库
我收到了有关该主题的错误,并且正在努力修复它。我使用带有多个嵌套 ARM 模板的 ARM 模板,部署是使用 Azure DevOps 完成的。
在模板下方。
第一个模板是调用嵌套模板的模板:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"existingDataFactoryName": {
"type": "string",
"metadata": {
"description": "Existing Data Factory name"
}
},
"existingDataFactoryResourceGroup": {
"type": "string",
"metadata": {
"description": "Existing Data Factory resource group"
}
},
"existingDataFactoryVersion": {
"type": "string",
"metadata": {
"description": "Select the existing Data Factory version"
},
"allowedValues": [
"V1",
"V2"
]
},
"virtualMachineName": {
"type": "string",
"metadata": {
"description": "Virtual Machine Name where the runtime will run. Please …Run Code Online (Sandbox Code Playgroud) 我使用Azure资源管理器(ARM)模板来部署我的Azure平台即服务(PaaS)资源.我将ARM模板部署作为"完成"执行,因此将删除模板中未定义的资源.
当我在Microsoft SQL Server PaaS数据库Azure资源上放置Azure资源锁,然后执行更改数据库名称的完整部署时,部署失败需要一个多小时.
资源组部署日志事件包含多个HTTP代码409错误,"无法执行删除操作,因为以下范围已被锁定:",但部署在DeploymentFailedCleanUp失败之前重试超过一小时.
我预计在删除资源和DeploymentFailedCleanup时都会出现冲突错误.如何在清理期间发生的409错误上快速部署失败?
azure azure-resource-manager azure-sql-database azure-rm-template
我有一个相当简单的 ARM 模板,用于创建 vnet、子网和服务端点。当我尝试更改服务端点时,我收到错误“代码”:“InUseSubnetCannotBeDeleted”。说明我的其中一台 VM 正在使用其中一个子网。但是,我不想删除该子网。我只想更新它,我可以通过门户或 powershell 进行的操作就好了。是否需要更改一些开关以使 ARM 模板更新资源而不是从头开始创建它们?
模板。我把它精简到最低限度。首先我用它来创建 vnet 和两个子网,部署一个 VM,然后再次运行部署,我得到子网无法删除:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vnetName": {
"type": "string",
"defaultValue": "VNet1",
"metadata": {
"description": "VNet name"
}
},
"vnetAddressPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/16",
"metadata": {
"description": "Address prefix"
}
},
"subnets": {
"type": "object"
}
},
"variables": {
"location": "[resourceGroup().location]",
"subnetcount": "[length(parameters('subnets').settings)]"
},
"resources": [
{
"apiVersion": "2018-06-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('vnetName')]",
"location": "[variables('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": ["[parameters('vnetAddressPrefix')]"]
}
},
"resources": …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Azure Web 应用程序的 AppConfig 部分中创建 KeyVault 引用。KeyVault 引用引用存在于 KeyVault 中的机密,该机密属于不同资源组的一部分,因此不存在于模板中。
根据文件的引用()模板函数,你应该能够引用的资源是不是模板的一部分,只要你提供完整的RESOURCEID和apiVersion。
但是当我用它来引用秘密时,我不断收到一个验证错误,它说:
错误:代码=无效模板;Message=部署模板验证失败:“模板中未定义资源“Microsoft.KeyVault/vaults//secrets/”。
我遵循了本指南。了解如何在 ARM 模板中使用 KeyVault 引用。
下面的代码是一个不起作用的情况的示例。
{
"type": "Microsoft.Web/sites",
"apiVersion": "2016-08-01",
"name": "[variables('webAppName')]",
"location": "[resourceGroup().location]",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('serverFarmName'))]",
"siteConfig": {
"alwaysOn": true,
"appSettings": [
{
"name": "<secretName>",
"value": "[concat('@Microsoft.KeyVault(SecretUri=', reference(variables('secretResourceId')).secretUriWithVersion, ')')]"
},
]
}
},
"identity": {
"type": "SystemAssigned"
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('serverFarmName'))]"
]
}
Run Code Online (Sandbox Code Playgroud)
变量定义如下:
"variables": {
"secretResourceId": "[resourceId(subscription().subscriptionId, parameters('keyVaultResourceGroup'), 'Microsoft.KeyVault/vaults/secrets', parameters('keyVaultName'), 'secretName')]"
},
Run Code Online (Sandbox Code Playgroud)
这是特定于对 KeyVault 机密的引用吗?
一旦我尝试相同但在模板中使用密钥库和秘密,它就可以正常工作。
azure azure-resource-manager azure-keyvault azure-web-app-service azure-rm-template
使用命令行开关部署通过主 ARM 模板模板化的链接 ARM 时New-AzureRmDeployment,我在尝试使用函数和属性时收到错误resourceGroup().name。错误信息是:
Unable to process template language expressions for resource
'/subscriptions/<subscriptionGuid>/resourceGroups/Zxy-
Test/providers/Microsoft.Resources/deployments/storageDeployment' at line
'29' and column '5'. 'The template function
'RESOURCEGROUP' is not expected at this location.`
Run Code Online (Sandbox Code Playgroud)
作为替代方案,我尝试使用resourceId(...)不带资源组函数调用的函数,但这给出了错误的资源 ID,其中资源组信息丢失并且与从 Azure 门户获取的资源 ID 不匹配。
例如
"value": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]"
Run Code Online (Sandbox Code Playgroud)
缺少资源组的结果:
/subscriptions/<subscriptionGuid>/providers/Microsoft.Storage/storageAccounts/linktestdata
Run Code Online (Sandbox Code Playgroud)
这是我所期望的,Azure 门户也报告了这一点
/subscriptions/<subscriptionGuid>/resourceGroups/Zxy-Test/providers/Microsoft.Storage/storageAccounts/linktestdata
Run Code Online (Sandbox Code Playgroud)
我有以下TestMaster.json模板TestLinked0.json作为示例来演示该问题。
测试大师.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"linkedTemplateUri": {
"type": "string",
"metadata": {
"description": "URI to the linked ARM template file."
} …Run Code Online (Sandbox Code Playgroud) 我正在 Azure 中部署虚拟机。用户名和密码是自动创建的,并在部署时作为参数传递。部署虚拟机的资源组也作为参数传递,因此可以是任何内容。
我的Keyvault位于特定资源组中,虚拟机的用户名和密码应存储在此处。
当 Keyvault 与虚拟机位于同一资源组中时,它可以正常工作。但是当它位于不同的资源组中时,我收到以下错误:
"error": {
"code": "ParentResourceNotFound",
"message": "Can not perform requested operation on nested resource. Parent resource 'mykeyvault' not found."
}
} undefined
Run Code Online (Sandbox Code Playgroud)
这是 ARM 模板的一部分,我在其中创建秘密。
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(variables('keyVaultName'), '/', variables('AdminUsername'))]",
"apiVersion": "2018-02-14",
"properties": {
"contentType": "Secret",
"value": "[variables('AdminUsername')]"
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('VMName'))]"
]
},
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(variables('keyVaultName'), '/', parameters('VMName'),'-AdminPassword')]",
"apiVersion": "2018-02-14",
"properties": {
"contentType": "Secret",
"value": "[parameters('AdminPassword')]"
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('VMName'))]"
]
},
Run Code Online (Sandbox Code Playgroud)
我还尝试将 keyVaultName 变量替换为 keyvault 的 …
在我当前的项目中,我正在使用 Azure AD 中预先创建的应用注册服务主体。我正在使用 ARM 模板创建一个 StorageV2 帐户和一些 blob 容器,然后创建一个 roleAssignment,为其中一个服务主体提供 Storage Blob Contributor 权限。ARM 模板的相关部分在本文末尾。
我发现,如果我将ObjectId普通 AD 用户(例如我自己或我的同事)的 设置为PrincipalId,则脚本可以正确运行。但是,我无法将其与服务主体一起使用。
如果我使用 Service Principal's ObjectId,则会收到以下错误:
Deployment failed. Correlation ID: 40e0c146-165a-47c0-b022-ac04781d8194. {
"error": {
"code": "PrincipalTypeNotSupported",
"message": "Principals of type Application cannot validly be used in role assignments."
}
}
Run Code Online (Sandbox Code Playgroud)
为 Azure Powershell 用户发现了一些我应该使用应用程序(客户端)ID 的建议后,我尝试了这一点,但出现以下错误(Guids 已编辑):
Deployment failed. Correlation ID: 5c725a51-230a-4d85-bb61-b2f4cdf849ff. {
"error": {
"code": "PrincipalNotFound",
"message": "Principal 9f****30 does not exist in the directory db****75."
} …Run Code Online (Sandbox Code Playgroud) azure-active-directory azure-resource-manager azure-rm-template
我很难理解name二头肌文件中丰富的属性。main.bicep我已经设置了自己的一些模块,在调用其中之一时看起来像这样:
module vas_resource_group '../common/resource_group.bicep' = {
name: 'vas_resource_group'
params: {
runningNumber: runningNumber
descriptionShort: descriptionShort
function: function
regionShort: regionShort
environment: environment
location: defaultLocation
}
}
Run Code Online (Sandbox Code Playgroud)
有问题的模块如下所示:
resource resource_group 'Microsoft.Resources/resourceGroups@2021-01-01' = {
name: 'rg-${runningNumber}-${descriptionShort}-${function}-${regionShort}-${environment}'
location: location
}
output name string = resource_group.name
Run Code Online (Sandbox Code Playgroud)
现在,main.bicep我想知道模块中声明的名称,例如我想知道模块决定将我的输入参数串在一起rg-${runningNumber}-${descriptionShort}-${function}-${regionShort}-${environment}。
在 中main.bicep,如果我写下这篇文章,我确信我会得到我想要的东西:
vas_resource_group.outputs.name
Run Code Online (Sandbox Code Playgroud)
但这有一个缺点,那就是它不能在任何地方使用,例如这是不允许的:
scope: resourceGroup(vas_resource_group.outputs.name)
Run Code Online (Sandbox Code Playgroud)
并显示错误:
该表达式用于对“模块”类型的“范围”属性的赋值,这需要一个可以在部署开始时计算的值。可以在开始时计算的 vas_resource_group 的属性包括“name”.bicep(BCP120)
因此,由于组成名称的所有构建块从一开始就已知,因此我不需要先创建资源,以便可以在部署之前计算名称。
然后,我选择引用资源组的名称,如下所示:
scope: resourceGroup(vas_resource_group.name)
Run Code Online (Sandbox Code Playgroud)
错误消失了,但我不知道这是否会导致声明的名称main.ps为vas_resource_group(无效),或者是否导致模块声明的名称为rg-${runningNumber}-${descriptionShort}-${function}-${regionShort}-${environment}.
它是哪一个,我应该如何考虑 name 属性?它有时似乎代表正在创建的资源的实际名称,而在其他时候(例如在调用模块中)根本没有多大用处。
如果是当前文件中的名称,如何以最佳方式获取模块中声明的名称?
有人可以举例说明如何在 arm 模板中引用“部署名称”?我打算使用它作为前缀,以便我可以将它连接到其他资源名称。
我在 stackoverflow 上发布了一些问题,并感谢那些花时间回答的人。尽管存在文档,但我仍然面临与输出功能相关的问题。
基本上我了解如何在格式为string时检索数据。不幸的是,当数据采用数组格式时,对我来说看起来更困难。
"outputs": {
"keyVaultName": {
"type": "string",
"value": "[variables('keyVaultName')]"
},
"websitesname": {
"type": "array",
"copy": {
"count": "[length(variables('webSitesName'))]",
"input": {
"name": "[variables('webSitesName')[copyIndex()].name]"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后我这样做:
$deploymentResult = New-AzResourceGroupDeployment -Name $deploymentName -ResourceGroupName
$ResourceGroupName-TemplateFile $TemplateFile
$vaultName = $deploymentResult.Outputs.keyVaultName.Value
$arrayWebsitesName = $deploymentResult.Outputs.websitesname.Value
Run Code Online (Sandbox Code Playgroud)
我需要从返回的数组中提取值。在 powershell 中我希望使用类似的东西
我相信有一些与转换相关的东西,我尝试convertto-json但没有成功。感谢您的帮助!