0

I am currently working on creating a bash script to automate azure managed sql instances. This is my current script:

export admin=<admin>
export password=<password>

az network vnet create \
  --name <name> \
  --resource-group <group-name> \
  --subnet-name <subnet-name>

az sql mi create -n <mi-name> -u $admin -p $password \
            --resource-group <group> -l "eastus" \
            --vnet-name <vnet-name> --subnet <rs-subnet> \

I am getting the following error

Deployment failed. Correlation ID: b3695d70-9175-4796-8280-e6c773e76213. . (https://go.microsoft.com/fwlink/?linkid=871071)

When you go to the page it says to configure the existing virtual network but they provide a powershell script and i'd like to use bash if that is the problem. Could someone help me convert the script to bash?

If the problem is something else please let me know.

Thanks!

5
  • I am not sure what <rs-subnet> is. When you create the Vnet you are calling --subnet-name <subnet-name> but it looks like you are using a different subnet name in the mi create. Commented Mar 1, 2019 at 1:04
  • See the article Create Azure SQL Managed Instance using Azure CLI. Commented Mar 1, 2019 at 1:10
  • Thank you! I really appreciate your help Commented Mar 4, 2019 at 15:29
  • @mshah49rs You could accept the answer if it is useful that will help more communities who have the same issue. Commented Mar 5, 2019 at 6:51
  • I accepted the answer sorry about that Commented Mar 9, 2019 at 17:53

1 Answer 1

1

Per our documentation for az sql mi create you need to supply the Name or ID of the subnet that allows access to an Azure Sql Managed Instance. If subnet name is provided, --vnet-name must be provided.

Something like this:

az sql mi create -g $rg -n $miname -l  $LOCATION -i -u $admin  -p $password --vnet-name $vnet --subnet $snet

You also need to ensure you have created a route table in the VNet. See https://blogs.msdn.microsoft.com/sqlserverstorageengine/2018/03/14/how-to-configure-network-for-azure-sql-managed-instance/

az network vnet create \
  --name $vnet \
  --resource-group $rg \
  --subnet-name $snet

az network route-table create -g $rg  -n MyRouteTable

az network route-table route create -g $rg --route-table-name MyRouteTable -n MiRoute \
   --next-hop-type Internet --address-prefix 0.0.0.0/0

az network vnet subnet update \
  --vnet-name $vnet  \
  --name $snet \
  --resource-group $rg \
  --route-table MyRouteTable
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.