We have a funky problem with the Azure SQL built in Export function (from the portal). If we export our DB there into a Bacpac file that is stored in a blob container, not all indexes get exported. We import them on a local SQL Server instance with SqlPackage.exe.
Two examples below. This one gets exported and imported:
CREATE NONCLUSTERED INDEX [nci_wi_st_person_AC4A694B12B4F4657C4CFA5FE6A67EA4] ON [dbo].[st_person]
(
[deleted] ASC,
[customer_status_id] ASC
)
INCLUDE([company_id],[created_date],[email],[first_name],[is_female],[job_title],[last_name],[pic_version],[work_phone]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
And this one not:
CREATE NONCLUSTERED INDEX [nci_wi_st_element_audit_log_41BBD3962CA4D455E09F7E3BCA557BD5] ON [dbo].[st_element_audit_log]
(
[element_type_id] ASC,
[element_id] ASC
)
INCLUDE([entry_type_id],[field_name],[field_type],[new_state_str],[previous_state_str],[recorded],[user_id]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
If we export the DB with
SqlPackage.exe /a:Export /ssn:$SourceServerName /sdn:$DatabaseName /tf:$TargetFilePath /su:$SourceServerUserName /sp:$SourceServerPassword
it works. Just via the Azure Portal some (not all) indexes are missing. On the portal we use the Export function as shown below:
