英文:
How to grep dnszone from azure SQL Managed Instance connection-string
问题
要求:自动化部署Azure SQL MI并连接Web应用程序。
每次我创建SQL MI时,它会生成一个随机的“dnszone”,我无法将其捕获到我需要使用bash命令创建连接字符串的文件中。下面是我使用的示例脚本:
$instanceName=sqlmi-poc
$dnszone=65r4897a552e <this i need to store>
jdbc:sqlserver://$instanceName.$dnszone.database.windows.net:1433;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.$dnszone.database.windows.net;loginTimeout=30;
我尝试了几种选项,但无法提取$dnszone的值:
Get-AzSqlInstance -ResourceGroupName {rg-name} -Name {mi-name}
az sql mi list -g $rgp | grep "fullyQualifiedDomainName"
我感谢任何帮助来捕获类似这样的dnszone值:
$dnszone="value"
英文:
Requirement: To automate the deployment of azure sql mi and connect the web application to it.
Everytime I create sql mi it generate a random "dnszone" which I am unable to capture in file which I need to create a connection string using bash command. below is sample scripts I have used:
$instanceName=sqlmi-poc
$dnszone=65r4897a552e <this i need to store>
jdbc:sqlserver://$instanceName.$dnszone.database.windows.net:1433;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.$dnszone.database.windows.net;loginTimeout=30;
I have tried couple of option available by unable to grep the $dnszone value
Get-AzSqlInstance -ResourceGroupName {rg-name} -Name {mi-name}
az sql mi list -g $rgp | grep "fullyQualifiedDomainName"
I appreciate any help to capture the dnszone value like this:
$dnszone="value"
Thanks
答案1
得分: 1
尝试以下类似的内容:
PS Azure:\> $dnszone = Get-AzSqlInstance -ResourceGroupName "rgouthindia" -Name "myinstancesouthindia*"
PS Azure:\> $dnszone.DnsZone
91d79b7f688b
英文:
Try something like below:
PS Azure:\> $dnszone =Get-AzSqlInstance -ResourceGroupName "rgouthindia" -Name "myinstancesouthindia*"
PS Azure:\> $dnszone.DnsZone
91d79b7f688b
答案2
得分: 0
finally after working for hours there is solution and thought to share it.
x="az sql mi list -g $rgp | grep "fullyQualifiedDomainName";"
chksqlmi=$(eval "$x")
y=$(echo $chksqlmi | tr -d ''"'"' '')
prefix="fullyQualifiedDomainName: $instanceName."
suffix=".database.windows.net,"
dnszone=$(echo $y | sed -e "s/^$prefix//" -e "s/$suffix$//")
英文:
finally after working for hours there is solution and thought to share it.
x="az sql mi list -g $rgp | grep "fullyQualifiedDomainName";"
chksqlmi=$(eval "$x")
y=$(echo $chksqlmi | tr -d '"')
prefix="fullyQualifiedDomainName: $instanceName."
suffix=".database.windows.net,"
dnszone=$(echo $y | sed -e "s/^$prefix//" -e "s/$suffix$//")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论