给定AzureRM模板中的以下资源,如何编码部件中的单引号commandToExecute?
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmNameMaster'), copyIndex(), '/sethost')]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"copy": {
"name": "extensionLoopNode",
"count": "[variables('masterCount')]"
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmNameMaster'), copyIndex(),'/extensions/DockerExtension')]"
],
"properties": {
"publisher": "Microsoft.OSTCExtensions",
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.4",
"settings": {
"fileUris": [ ],
"commandToExecute": "[concat('/bin/bash -c \'echo \"export DOCKER_HOST=:2375\" >> /home/', parameters('adminUsername') ,'/.profile\'')]",
"timestamp": 123456789
}
}
},
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
我正在尝试验证ResourceGroup是否存在所以我认为以下代码应返回true或false,但它不输出任何内容.
$RSGtest = Find-AzureRmResource | Format-List ResourceGroupName | get-unique
$RSGtest -Match "$myResourceGroupName"
Run Code Online (Sandbox Code Playgroud)
为什么我没有得到任何输出?
我正在使用二头肌来创建天蓝色资源。这些资源之一是服务总线,其定义如下:
resource service_bus 'Microsoft.ServiceBus/namespaces@2021-01-01-preview' = {
name: '${service_bus_name}${uniqueString(service_bus_name)}'
location: resourceGroup().location
sku: {
name: 'Standard'
tier: 'Standard'
}
properties: {}
}
Run Code Online (Sandbox Code Playgroud)
然后,我想在另一个资源中使用此服务总线,这就是我当前的连接字符串:
name: 'AzureWebJobsServiceBus'
value: 'Endpoint=sb://${service_bus.name}.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=<hardcoded_key>'
Run Code Online (Sandbox Code Playgroud)
如何避免硬编码密钥。我尝试像这样使用 listKeys:
SharedAccessKey=${listKeys(service_bus.id, service_bus.apiVersion).value[0].primaryKey}
Run Code Online (Sandbox Code Playgroud)
但这是行不通的,而且它的变种也失败了。
我正在部署一个ARM模板,该模板使用复制资源块将一个或多个数据磁盘部署到VM.我想做的是将其更改为0或更多.
我使用的参数是
"VirtualMachineDiskSizeArray": {
"type": "array",
"defaultValue": [ "100" ]
},
Run Code Online (Sandbox Code Playgroud)
然后在资源中调用它:
"resources": [
{
"name": "[parameters('virtualMachineName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2016-04-30-preview",
"location": "[parameters('rgLocation')]",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', parameters('rgStorageAccountName'))]"
],
"properties": {
"osProfile": { ... },
"hardwareProfile": { ... },
"storageProfile": {
"imageReference": { ... },
"osDisk": { ... },
"copy": [
{
"name": "dataDisks",
"count": "[length(parameters('VirtualMachineDiskSizeArray'))]",
"input": {
"lun": "[copyIndex('dataDisks')]",
"name": "[concat(parameters('vmDataDiskNameStub'), add(copyIndex('dataDisks'),1), '.vhd')]",
"diskSizeGB": "[parameters('VirtualMachineDiskSizeArray')[copyIndex('dataDisks')]]",
"createOption": "Empty",
"vhd": {
"uri": "[concat(concat(reference(resourceId(parameters('rgName'), 'Microsoft.Storage/storageAccounts', parameters('rgStorageAccountName')), '2015-06-15').primaryEndpoints['blob'], 'vhds/'), concat(parameters('vmDataDiskNameStub'), add(copyIndex('dataDisks'),1), '.vhd') )]"
} …Run Code Online (Sandbox Code Playgroud) 主二头肌
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
我正在寻找一种通过ARM模板在Azure blob和文件共享存储中创建容器的方法.
目前我有ARM模板来配置存储帐户,但我想在ARM中创建容器.
{
"name": "[parameters('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"location": "[resourceGroup().location]",
"apiVersion": "[variables('storageApiVersion')]",
"sku": {
"name": "[variables('storageAccountType')]"
},
"dependsOn": [ ],
"tags": {
"Environment": "[parameters('Environment')]",
"Project": "[parameters('ProjectName')]",
"Contact": "[parameters('ContactName')]"
},
"kind": "Storage",
"properties": {
"encryption": {
"keySource": "Microsoft.Storage",
"services": {
"blob": {
"enabled": true
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud) azure azure-storage azure-storage-blobs azure-resource-manager azure-storage-files
我有以下设置:
我想移动App Service 3进入Resource group 2但使用app service plan 1,到app service plan 2.
这可能吗?我尝试使用新门户网站上提供的"更改应用服务计划"功能,但当我点击它时,刀片显示"未找到应用服务计划".
我怀疑刀片服务器在原始资源组中查找可用的应用服务计划,并且不允许创建新服务器计划.
有关详细信息,请参阅附图.
谢谢
我遇到Azure PS模块的问题.我通过PS库安装了以下内容:
Install-Module AzureRM
Install-Module Azure
Run Code Online (Sandbox Code Playgroud)
(并重新启动)
但是,当我运行时,Login-AzureRmAccount我收到以下错误:
Login-AzureRmAccount:术语"Login-AzureRmAccount"未被识别为cmdlet,函数,脚本文件或可操作程序的名称.检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试.在行:1 char:1 + Login-AzureRmAccount + ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:ObjectNotFound :( Login-AzureRmAccount:String)[],CommandNotFoundException + FullyQualifiedErrorId :CommandNotFoundException
我似乎安装了所有Azure模块.即如果我跑,Get-Module -List我得到关注.
Script 3.7.0 Azure {Get-AzureAutomationCertificate, Get-AzureAutomationConnec...
Script 0.1.0 Azure.AnalysisServices {Add-AzureAnalysisServicesAccount, Restart-AzureAnalysisSe...
Script 2.7.0 Azure.Storage {Get-AzureStorageTable, New-AzureStorageTableSASToken, New...
Script 3.7.0 AzureRM {Update-AzureRM, Import-AzureRM, Uninstall-AzureRM, Instal...
Script 0.1.0 AzureRM.AnalysisServices {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnal...
Script 3.5.0 AzureRM.ApiManagement {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementS...
Script 2.7.0 AzureRM.Automation {Get-AzureRMAutomationHybridWorkerGroup, Get-AzureRmAutoma...
Script 2.7.0 AzureRM.Backup {Backup-AzureRmBackupItem, Enable-AzureRmBackupContainerRe...
Script 2.7.0 AzureRM.Batch {Remove-AzureRmBatchAccount, Get-AzureRmBatchAccount, Get-...
Script 2.7.0 AzureRM.Cdn {Get-AzureRmCdnProfile, …Run Code Online (Sandbox Code Playgroud) 我一直在梳理Powershell 命令,试图找出如何使用我当前部署的网站/ SQL数据库/存储帐户并将它们移动到自己的资源组中.
是否可以在资源组之间移动Azure"资源"?或者我是否总是需要创建新资源并将数据/代码迁移到这些新资源中?