是否知道如何使用reference function引用azure资源模板中的现有资源组。
我想知道一个特定资源的位置(西欧,西美等),因为我需要作为另一个资源的输入。我引用的资源不在同一资源组中
答案 0 :(得分:0)
你应该使用@ECHO OFF
setlocal
SET Location_Folder=V:
SET Destination_folder=V:\Nonimportable
SET Check_file_validation=V:\Nonimportable\result.txt
SET Excluded_folder=Nonimportable
set "lineNr=12"
For /f "tokens=*" %%O in ('dir /b /a:d "%Location_Folder%"') do (
set filename=%%O
call D:\somefolder\otherfolder\batscriptname.bat %%O
set Validation=
echo %%O| FINDSTR /i /c:"%Excluded_folder%" >NUL
IF ERRORLEVEL 1 (
for /F "skip=12 delims=" %%a in (%Check_file_validation%) do if not defined Validation (
set Validation=%%a
call :valid
)
) else (
echo This folder name is excluded: %%O
)
)
goto Finish
:valid
set Folder_path=%Location_Folder%\%filename%
set New_Folder_path=%Destination_folder%\%filename%
echo %Validation%| FINDSTR /c:"1" >NUL
if ERRORLEVEL 1 (
mkdir "%New_Folder_path%"
echo D | xcopy /o /y /q /s /v "%Folder_path%" "%New_Folder_path%"
rmdir /s /q "%Folder_path%"
) else (
echo Folder is valid %filename%
rem redundant instruction : goto Finish
)
:Finish
exit /b
功能:
concat
编辑:伙计,我今天很傻。
答案 1 :(得分:0)
如果我们想要使用ARM创建流量管理器并配置azureEndpoints
端点。 我们无需添加位置属性。我们可以通过目标资源ID得到它,以下是我的测试代码,它对我来说正常。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"variables": {
"tmApiVersion": "2015-11-01"
},
"resources": [
{
"apiVersion": "[variables('tmApiVersion')]",
"type": "Microsoft.Network/trafficManagerProfiles",
"name": "azureendpointexample",
"location": "global",
"properties": {
"profileStatus": "Enabled",
"trafficRoutingMethod": "Performance",
"dnsConfig": {
"relativeName": "azureendpointexample",
"ttl": 30
},
"monitorConfig": {
"protocol": "http",
"port": 80,
"path": "/"
},
"endpoints": [
{
"name": "tomtest",
"type": "Microsoft.Network/trafficManagerProfiles/azureEndpoints",
"properties": {
"endpointStatus": "Enabled",
"endpointMonitorStatus": null,
"targetResourceId": "[resourceId('resourcegroup', 'Microsoft.Web/sites/', 'websitename')]",
"target": "azureendpointexample.azurewebsites.net",
"weight": 1,
"priority": 1
}
}
]
}
}
]
}
答案 2 :(得分:0)
并非所有资源都支持返回该位置(请记住一些是地理冗余的)可能在问题背后更详细,即您尝试连接的资源可能会有所帮助。
以下是获取主存储位置的示例:
[reference(resourceId(parameters('storageAccountResourceGroup'), 'Microsoft.Storage/storageAccounts/', parameters('storageAccountName'), '2016-01-01').primaryLocation]
但对于像VM的VHD这样的东西,托管磁盘会更容易......所以了解更多关于这种情况可能会带来更好的解决方案...